-
Notifications
You must be signed in to change notification settings - Fork 34
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-django doesn't report error if flake8 was ran under pre-commit #118
Comments
I can confirm the same issue when tested with DJ12. I put some quick
I get all of the expected output, including an "I should yield dj12", but flake8 passes. When I just run flake8 normally, including using the one installed in the pre-commit managed venv, I do get the DJ12 error. |
@BigDeepBlue Found it. Looks like |
It happens because pre-commit runs flake8 in separate environment from your development environment(where django not installed). So it can't detect if class is model or not, because it can't check is it inherited from |
I stuck with the issue that if I run flake8 admin.py manually - I see error DJ07, but when I try to do that in pre-commit hook, check passes silently. So.
Python 3.9.16 (main, Mar 10 2023, 13:37:42)
[Clang 14.0.0 (clang-1400.0.29.202)] on darwin
admin.py
pyproject.toml
.pre-commit-config.yaml
requirements.txt
so when I created virtualenv and install there deps from requirements.txt, then I ran
So here I can see error from your plugin, well
Then if I do
git add admin.py
then runso in that case no violations were raised.. ( Don't have and idea why, I see from logs that plugin was loaded and in both cases I see in logs line -
flake8.checker MainProcess 278 DEBUG Logical line: "fields = "xxxxxxx""
, but in case when it was run under pre-commit the DJ* was not found.my git diff --stashed
so I'm sure it should raise DJ07 error.
The text was updated successfully, but these errors were encountered: