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

Errors on names of migrations #167

Open
karyon opened this issue Jun 23, 2018 · 15 comments
Open

Errors on names of migrations #167

karyon opened this issue Jun 23, 2018 · 15 comments

Comments

@karyon
Copy link

karyon commented Jun 23, 2018

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.

@karyon
Copy link
Author

karyon commented Jun 23, 2018

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 #165 as well :)

using pylint 1.9.2, pylint-django 0.11.1, python 3.6.5, on windows.

any help would be appreciated.

@atodorov
Copy link
Contributor

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.

@karyon
Copy link
Author

karyon commented Jun 25, 2018

it's pylint.exe evap.

folder structure see https://github.com/fsr-itse/EvaP/, or see this screenshot

@atodorov
Copy link
Contributor

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.

@karyon
Copy link
Author

karyon commented Jun 25, 2018

as i said i have enabled the plugin in my .pylintrc. I get the very same errors when using --load-plugins pylint_django.

@atodorov
Copy link
Contributor

Well then post your .pylinrc if you want to get some help. Don't make me search for things.

@karyon
Copy link
Author

karyon commented Jun 25, 2018

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.

@atodorov
Copy link
Contributor

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.

@karyon
Copy link
Author

karyon commented Jun 29, 2018

yes, thank you. sorry for the cumbersome communication with me.

@atodorov
Copy link
Contributor

Either a bug in pylint or desired behavior. Waiting for info:
https://mail.python.org/pipermail/code-quality/2018-June/001033.html

@atodorov
Copy link
Contributor

atodorov commented Aug 6, 2018

@PCManticore can you comment on the above comment/email thread ?

@PCManticore
Copy link

@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.

@atodorov
Copy link
Contributor

@karyon can you reproduce with the latest version ? It looks like this may have been fixed meanwhile.

@karyon
Copy link
Author

karyon commented Apr 28, 2019

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.

@JensTimmerman
Copy link

JensTimmerman commented Aug 6, 2021

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

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

4 participants