pylint-django
pylint-django copied to clipboard
Errors on names of migrations
I'm getting lots of warnings on my migrations, e.g.:
Module name "0056_alter_userprofile_email" doesn't conform to '(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$' pattern (invalid-name)
if this code here is supposed to prevent any errors on migrations error, it doesn't work :) if it's not supposed to do that, i would feature request that these migrations names are allowed by default.
okay, i'm getting other errors as well that should be suppressed by pylint-django in my understanding, e.g. Constant name "app_name" doesn't conform to UPPER_CASE naming style. however, i have pylint_django specified in pylint's load-plugins setting, and pylint-django does change the output, e.g. i'm seeing https://github.com/PyCQA/pylint-django/issues/165 as well :)
using pylint 1.9.2, pylint-django 0.11.1, python 3.6.5, on windows.
any help would be appreciated.
So the first error is because module name starts with a digit, not a letter (if I read the regexp correctly).
Can you post your command line by which you invoke pylint and also the directory structure around your migrations.
I'm not getting such errors for one of my Django projects and we do have lots of migrations.
it's pylint.exe evap.
folder structure see https://github.com/fsr-itse/EvaP/, or see this screenshot
it's pylint.exe evap.
this isn't invoking pylint-django. If this is your command line then pylint is working as expected b/c you are not enabling the pylint-django plugin.
as i said i have enabled the plugin in my .pylintrc. I get the very same errors when using --load-plugins pylint_django.
Well then post your .pylinrc if you want to get some help. Don't make me search for things.
i have narrowed it down to this: the default .pylintrc file contains ignore=CVS, and with that i get the erroneous warnings. when removing that part, i do not get these warnings.
To summarize: when .pylintrc contains an ignore= line this somehow breaks our blacklist and the linter is executed against the migrations directory. Now this is something I can try and look at.
yes, thank you. sorry for the cumbersome communication with me.
Either a bug in pylint or desired behavior. Waiting for info: https://mail.python.org/pipermail/code-quality/2018-June/001033.html
@PCManticore can you comment on the above comment/email thread ?
@atodorov this is a bit of an undefined behaviour. There's currently no guarantee for the plugins to get the fully loaded configuration file at the time they are registered. But you might check here if moving the plugin loading after the configuration loading would help you, but I don't know if that can have any side effects or not.
@karyon can you reproduce with the latest version ? It looks like this may have been fixed meanwhile.
I cannot say conclusively, because pylint crashes before finishing the analysis, but it seems it is completing analysis of the app which contains those migrations before crashing, and it does not report anything for the migrations in that app, regardless of whether an ignore= setting is present or not.
i guess that's the intended behavior, always ignoring the migration directories? if that's the case, i would feature request the option to disable that. migrations can contain considerable amount of code as well (especially when using RunPython), and I think it's wrong to not get any pylint warnings in that code.
I am also seeing this issue
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: .pylintrc
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ [MASTER]
2 │ load-plugins=pylint_django
3 ~ │ django-settings-module=nmgfitness.settings
4 │
5 │ [FORMAT]
6 │ max-line-length=120
7 │
8 │ [MESSAGES CONTROL]
9 │ disable=missing-docstring,unnecessary-pass
10 │
11 │ [DESIGN]
12 │ max-parents=13
13 │
14 │ [TYPECHECK]
15 │ generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete
pylint --rcfile=.pylintrc -- **/*.py 13.6s Fri 06 Aug 2021 11:48:34 PM CEST
************* Module nmgfitness.migrations.0001_initial
nmgfitness/migrations/0001_initial.py:1:0: C0103: Module name "0001_initial" doesn't conform to snake_case naming style (invalid-name)
************* Module nmgfitness.migrations.0002_auto_20210805_2157
nmgfitness/migrations/0002_auto_20210805_2157.py:1:0: C0103: Module name "0002_auto_20210805_2157" doesn't conform to snake_case naming style (invalid-name)
------------------------------------------------------------------
Your code has been rated at 9.85/10 (previous run: 9.85/10, +0.00)
I solved this by adding
ignore-paths=.*/migrations
to my .pylintrc