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

flake8 per-file-ignores not read from setup.cfg? #730

Closed
janosh opened this issue Jul 10, 2022 · 3 comments · Fixed by #732
Closed

flake8 per-file-ignores not read from setup.cfg? #730

janosh opened this issue Jul 10, 2022 · 3 comments · Fixed by #732

Comments

@janosh
Copy link
Contributor

janosh commented Jul 10, 2022

[flake8]
# general ignore works
ignore = E402
per-file-ignores =
  # per-file ignore doesn't work
  examples/*.ipynb: E402

If I remove ignore = E402, I still get

$ nbqa flake8 examples/*.ipynb
                  
examples/foo.ipynb:cell_9:2:1: E402 module level import not at top of file

if I leave it in, the error disappears so setup.cfg is read but per-file-ignores apparently isn't?

@MarcoGorelli
Copy link
Collaborator

Hey @janosh

This is because nbQA converts jupyter notebooks to temporary Python files, and then runs whatever tool you've specified over them

It's a limitation of the tool, not sure what can be done here, other than perhaps to add a note about this in the docs

@janosh
Copy link
Contributor Author

janosh commented Jul 11, 2022

It looks like tempfiles have access to the original file name

nbQA/nbqa/__main__.py

Lines 60 to 64 in 3d7afb0

class TemporaryFile(NamedTuple):
"""Temporary file and file descriptor."""
fd: int
file: str

So maybe when running flake8, nbqa could check if the original's name matches anything under per-file-ignores and then insert that error code into the --ignore flag.

But maybe too much hassle. In any case, documenting this limitation would be good! Happy to submit a PR. Should it go here?

@MarcoGorelli
Copy link
Collaborator

In any case, documenting this limitation would be good! Happy to submit a PR. Should it go here?

Thanks! I think here might be better https://nbqa.readthedocs.io/en/latest/known-limitations.html ?

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 a pull request may close this issue.

2 participants