Skip to content

Add autoformat option to CLI - #1395

Merged
david-yz-liu merged 4 commits into
pyta-uoft:masterfrom
PraneethS42:add-cli-autoformat
Sep 27, 2026
Merged

david-yz-liu merged 4 commits into
pyta-uoft:masterfrom
PraneethS42:add-cli-autoformat

Conversation

@PraneethS42

@PraneethS42 PraneethS42 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

These changes update the PyTA CLI to take an option --autoformat. When enabled, PyTA runs Black on the supplied files before analyzing them, matching the pre-existing autoformat=True argument in check_all and check_errors.

The option is forwarded through all CLI configuration paths, and remains disabled by default. Created tests cover both checker modes and the default behaviour.

...

Screenshots of your changes (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
✨ New feature (non-breaking change that adds functionality) x
🐛 Bug fix (non-breaking change that fixes an issue)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • I have updated the project Changelog (this is required for all changes).
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@coveralls

coveralls commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 36092919400

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.004%) to 90.911%

Details

  • Coverage increased (+0.004%) from the base build.
  • Patch coverage: 7 of 7 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4082
Covered Lines: 3711
Line Coverage: 90.91%
Coverage Strength: 17.67 hits per line

💛 - Coveralls



def _invoke_checker(checker, paths, config, output_format):
def _invoke_checker(checker, paths, config, output_format, autoformat):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a type annotation for the autoformat parameter (this will make merging with @rachelzUT's current task easier later)

Comment thread packages/python-ta/tests/test_main.py Outdated

def fake_checker(*, module_name, **kwargs):
calls.append({"module_name": module_name, "kwargs": kwargs})
def fake_checker(*, module_name, autoformat):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's improve the existing pattern of the fake_checker (throughout this file).

  1. Modify the __main__.py file itself to pass all of the arguments to check_all/check_errors as keyword arguments instead of positional arguments.

  2. Pull out the definition of fake_checker into a single factory function instead of redefining it in all tests. The factory function should take in calls and return the actual fake_checker function.

    def mock_checker(calls: list) -> Callable[..., BaseReporter]:
  3. The interface for the inner fake_checker function should just be to take module_name and **kwargs and store them in calls, like the original code here did. You can extract specific keyword arguments from kwargs in the individual test cases.

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @PraneethS42!

@david-yz-liu
david-yz-liu merged commit 6646552 into pyta-uoft:master Sep 27, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants