Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linting feedback and helpful commands #3

Open
chrismeyersfsu opened this issue Aug 15, 2024 · 3 comments
Open

linting feedback and helpful commands #3

chrismeyersfsu opened this issue Aug 15, 2024 · 3 comments

Comments

@chrismeyersfsu
Copy link
Member

chrismeyersfsu commented Aug 15, 2024

Initially, we want to understand which linter is doing what. One way to do this is to comment out all the linters in .pre-commit-config.yaml except the one you want to focus on. That's not the best experience.

We found the below command to work best for the above flow

tox -e pre-commit -- --all-files pyupgrade where pyupgrade is found in .pre-commit-config.yaml in id, under hooks

- hooks:
    - id: pyupgrade

Note that if you are googling around you might think the command you want is tox -e pre-commit -- pyupgrade but if you look in tox.ini you will find the below. Note the {posargs:--all-files} {posargs} is referring to the portion after --, the {:--all-files} is the default value to use if no position args are specified. It looks like the intent of this version of commands is to easily allow for running all linters against a single or few command-line specified files. In our initial exploration use case, we want to run one linter against all files.

[testenv:pre-commit]
description = Run the quality checks under {basepython}
commands =
  {envpython} -Im \
    pre_commit run \
    --show-diff-on-failure \
    {posargs:--all-files}
@webknjaz
Copy link
Member

Oh, you could've just asked me :)

By the way, provided we're going to rewrite history more with that test file, I think it's best to skip running any formatters until that work is done. Otherwise, it'll get erased. Usually, you can't meaningfully rebase/cherry-pick mass-formatting commits.

A trick for skipping certain checks is to declare a SKIP environment variable with comma-separated check ids. I've just plugged bypassing that var into tox. Hope that helps!

@webknjaz
Copy link
Member

I also added a longer explanation into tox -av.

@webknjaz
Copy link
Member

I also added a longer explanation into tox -av.

UPD: The tox4 variant of the command is tox l

@webknjaz webknjaz pinned this issue Aug 27, 2024
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

No branches or pull requests

2 participants