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

Warning on import not in VAGUE_IMPORTS_BLACKLIST #1018

Closed
slavyanskii opened this issue Nov 21, 2019 · 2 comments
Closed

Warning on import not in VAGUE_IMPORTS_BLACKLIST #1018

slavyanskii opened this issue Nov 21, 2019 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed level:starter Good for newcomers

Comments

@slavyanskii
Copy link

Bug report

What's wrong

WPS347 showing warning on django F and Q imports, but according to link it's not in black list

Code example

from django.db.models import Q, F

after flakehell: WPS347: Found vague import that may cause confusion: Q

flake8 information

Contents of flake8 --bug-report:

{
  "dependencies": [
    {
      "dependency": "entrypoints",
      "version": "0.3"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.7.3",
    "system": "Darwin"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "flake8-annotations-complexity",
      "version": "0.0.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-bandit",
      "version": "2.1.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-blind-except",
      "version": "0.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-broken-line",
      "version": "0.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-bugbear",
      "version": "19.8.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-comprehensions",
      "version": "3.1.4"
    },
    {
      "is_local": false,
      "plugin": "flake8-darglint",
      "version": "0.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-debugger",
      "version": "3.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.5.0, pydocstyle: 4.0.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-eradicate",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-executable",
      "version": "2.0.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-print",
      "version": "3.1.4"
    },
    {
      "is_local": false,
      "plugin": "flake8-return",
      "version": "0.1.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-string-format",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_builtins",
      "version": "1.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_coding",
      "version": "1.3.2"
    },
    {
      "is_local": false,
      "plugin": "flake8_commas",
      "version": "2.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8_isort",
      "version": "2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_pep3101",
      "version": "1.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_quotes",
      "version": "2.1.1"
    },
    {
      "is_local": false,
      "plugin": "logging-format",
      "version": "0.6.0"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "naming",
      "version": "0.9.1"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.5.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.1.1"
    },
    {
      "is_local": false,
      "plugin": "pylint",
      "version": "2.4.4"
    },
    {
      "is_local": false,
      "plugin": "radon",
      "version": "2.4.0"
    },
    {
      "is_local": false,
      "plugin": "rst-docstrings",
      "version": "0.0.11"
    },
    {
      "is_local": false,
      "plugin": "wemake-python-styleguide",
      "version": "0.13.0"
    }
  ],
  "version": "3.7.8"
}

pip information

Contents of pip freeze:

astor==0.8.0
astroid==2.3.3
attrs==19.1.0
bandit==1.6.2
black==19.3b0
cached-property==1.5.1
cachetools==3.1.1
certifi==2019.6.16
chardet==3.0.4
Click==7.0
cognitive-complexity==0.0.4
colorama==0.3.9
coreapi==2.3.3
coreschema==0.0.4
darglint==1.1.0
Django==2.2.6
django-debug-toolbar==1.11
django-filter==2.2.0
django-storages==1.7.1
djangorestframework==3.10.3
dnspython==1.16.0
docutils==0.15.2
dparse==0.4.1
drf-yasg==1.17.0
entrypoints==0.3
eradicate==1.0
eventlet==0.25.0
flake8==3.7.8
flake8-annotations-complexity==0.0.2
flake8-bandit==2.1.2
flake8-blind-except==0.1.1
flake8-broken-line==0.1.1
flake8-bugbear==19.8.0
flake8-builtins==1.4.1
flake8-coding==1.3.2
flake8-commas==2.0.0
flake8-comprehensions==3.1.4
flake8-debugger==3.2.1
flake8-docstrings==1.5.0
flake8-eradicate==0.2.3
flake8-executable==2.0.3
flake8-isort==2.7.0
flake8-logging-format==0.6.0
flake8-pep3101==1.2.1
flake8-plugin-utils==1.0.0
flake8-polyfill==1.0.2
flake8-print==3.1.4
flake8-pytest-style==0.1.3
flake8-quotes==2.1.1
flake8-rst-docstrings==0.0.11
flake8-string-format==0.2.3
flakehell==0.3.1
gitdb2==2.0.6
GitPython==3.0.5
google-api-core==1.13.0
google-auth==1.6.3
google-cloud-core==1.0.2
google-cloud-storage==1.16.1
google-resumable-media==0.3.2
googleapis-common-protos==1.6.0
greenlet==0.4.15
gunicorn==19.9.0
idna==2.8
importlib-metadata==0.23
inflection==0.3.1
isort==4.3.15
itypes==1.1.0
Jinja2==2.10.1
lazy-object-proxy==1.4.3
mando==0.6.4
MarkupSafe==1.1.1
mccabe==0.6.1
model-mommy==1.6.0
monotonic==1.5
more-itertools==7.2.0
multidict==4.5.2
mypy==0.730
mypy-extensions==0.4.3
packaging==19.0
patch==1.16
pbr==5.4.3
pep8-naming==0.9.1
protobuf==3.9.0
psycopg2-binary==2.8.3
pyasn1==0.4.5
pyasn1-modules==0.2.5
pycodestyle==2.5.0
pydocstyle==4.0.1
pyflakes==2.1.1
Pygments==2.4.2
pyinstrument==3.0.3
pyinstrument-cext==0.2.2
pylint==2.4.4
pyparsing==2.4.1.1
pytz==2019.1
PyYAML==4.2b4
radon==2.4.0
requests==2.22.0
restructuredtext-lint==1.3.0
rsa==4.0
ruamel.yaml==0.15.98
safety==1.8.5
sentry-sdk==0.13.0
six==1.12.0
smmap2==2.0.5
snowballstemmer==2.0.0
sqlparse==0.3.0
stevedore==1.31.0
termcolor==1.1.0
testfixtures==6.10.2
toml==0.10.0
typed-ast==1.4.0
typing-extensions==3.7.4.1
uritemplate==3.0.0
urllib3==1.25.3
wemake-python-styleguide==0.13.0
wrapt==1.11.2
xenon==0.5.5
yarl==1.3.0
zipp==0.6.0
@slavyanskii slavyanskii added the bug Something isn't working label Nov 21, 2019
@sobolevn sobolevn added this to the Version 0.13.x milestone Nov 21, 2019
@sobolevn sobolevn added help wanted Extra attention is needed level:starter Good for newcomers labels Nov 21, 2019
@sobolevn
Copy link
Member

Thanks a lot for the bug report! @slavyanskii do you want to fix it?

@sobolevn
Copy link
Member

Done! I have improved the docs for this violation.

Names that we forbid to import:
    - Common names like ``dumps`` and ``loads``
    - Names starting with ``to_`` and ``from_``
    - Too short names like ``Q`` or ``F``, but we are fine with ``_``

Solutions for your case:

# 1
from django.db import models

models.Q(...)
models.F(...)

# 2
from django.db.models import Q as Query
from django.db.models import F as Field

Related to #814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed level:starter Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants