JBKahn / flake8-print

flake8
MIT License
119 stars 22 forks source link

Directory based subset #44

Closed henryiii closed 2 years ago

henryiii commented 4 years ago

Is there a way to select a directory? I really only care about prints in my package; in scripts, examples, and tests they are valid. I want to keep running the rest of flake8 on the other directories, though. I think I can make this work via pre-commit and splitting the check in two, but is there a better way? Thank you for this useful package!

henryiii commented 4 years ago

My problem was solved like this in pre-commit, but still wondering if there is a flake8 way to solve it:

- repo: https://github.com/pycqa/flake8
  rev: 3.8.3
  hooks:
  - id: flake8
    exclude: docs/conf.py
    additional_dependencies: [flake8-bugbear]
  - id: flake8
    name: Print check
    files: src
    additional_dependencies: [flake8-print]
    args:
      - --select
      - T
henryiii commented 4 years ago

Got some help, the solution is, from @asottile :

ah, I would combine the two and use per-file-ignores in your flake8 configuration

something like

additional_dependencies: [flake8-bugbear, flake8-print]

and then

[flake8]
per-file-ignores =
    tests/*: T

(or whatever the code is for flake8-print)

Many an example showing that (since it's quite important for this plugin) would be helpful?

JBKahn commented 3 years ago

Since this is a core feature of flake8 I'm not sure I want to add that into the docs here since the ones for flake8 are already really good: https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-per-file-ignores

MartinThoma commented 3 years ago

It might be a core feature of flake8, but in most cases people don't need it. For print, I see that this is more often a decision per directory than many other coding style decisions.

JBKahn commented 3 years ago

That's fair, how would you add it to the ReadMe?

JBKahn commented 2 years ago

Merged your suggestion into the documentation.