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

False-positive 405 & 414 on loop unpacking #1684

Closed
pawamoy opened this issue Oct 20, 2020 · 8 comments
Closed

False-positive 405 & 414 on loop unpacking #1684

pawamoy opened this issue Oct 20, 2020 · 8 comments
Labels
bug Something isn't working good first issue Entrypoint to the project Hacktoberfest Hactoberfest fun! help wanted Extra attention is needed level:starter Good for newcomers

Comments

@pawamoy
Copy link
Contributor

pawamoy commented Oct 20, 2020

Bug report

What's wrong

for kind, (model_class, list_model_class) in mapping.items():
    ...  # do things

...triggers WPS405 and WPS414.

405 says:

Use regular ast.Name variables. Or tuple of ast.Name variables. Star names are also fine.

I'm using a name and a tuple with two names. This should be OK right?

414 says to avoid side-effects. There are no side-effects when unpacking into kind, (model_class, list_model_class).

How it should work

No 405 or 414 triggered.

System information

flake8 information

Contents of flake8 --bug-report:

{
  "dependencies": [],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.12",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "black",
      "version": "0.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-bandit",
      "version": "2.1.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-broken-line",
      "version": "0.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-bugbear",
      "version": "19.8.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-comprehensions",
      "version": "3.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-darglint",
      "version": "1.5.5"
    },
    {
      "is_local": false,
      "plugin": "flake8-debugger",
      "version": "3.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.5.0, pydocstyle: 5.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-eradicate",
      "version": "0.3.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-string-format",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-tidy-imports",
      "version": "4.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-variables-names",
      "version": "0.0.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_builtins",
      "version": "1.5.2"
    },
    {
      "is_local": false,
      "plugin": "flake8_commas",
      "version": "2.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8_isort",
      "version": "3.0.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_quotes",
      "version": "2.1.2"
    },
    {
      "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.6.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.2.0"
    },
    {
      "is_local": false,
      "plugin": "pylint",
      "version": "2.6.0"
    },
    {
      "is_local": false,
      "plugin": "rst-docstrings",
      "version": "0.0.12"
    },
    {
      "is_local": false,
      "plugin": "wemake_python_styleguide",
      "version": "0.14.1"
    }
  ],
  "version": "3.8.4"
}

pip information

Contents of pip freeze: sorry lots of private stuff, can sanitize and post if needed.

@pawamoy pawamoy added the bug Something isn't working label Oct 20, 2020
@sobolevn sobolevn added this to the Version 0.15 aka New runtime milestone Oct 20, 2020
@sobolevn sobolevn added good first issue Entrypoint to the project Hacktoberfest Hactoberfest fun! help wanted Extra attention is needed level:starter Good for newcomers labels Oct 20, 2020
@Ajax-Light
Copy link

Ajax-Light commented Oct 28, 2020

Hey, is this issue still open? I'd like to try my hand at it. I am at a loss for choosing a starting point though, any pointers would be appreciated 😊

@sobolevn
Copy link
Member

Yes, @Ajax-Light! Thanks a lot!

@sobolevn
Copy link
Member

We need to fix this line:

self.add_violation(LoopVariableDefinitionViolation(node))

And this:

best_practices.WrongUnpackingViolation(node),

@Ajax-Light
Copy link

Hey @sobolevn ! Ran into some issues setting up the Dev-environment.

  1. Can I safely ignore the warnings by flake8 here:
    image
    I looked through the files and they don't seem to be harmful.
  2. I'm new to virtualenv, so should i always run wps inside a virtualenv generated by poetry shell?

I'm new to this production-grade stuff, sorry for being a bother 😅

@Ajax-Light
Copy link

Ajax-Light commented Oct 29, 2020

Never mind! I found the solution in the tutorial, I forget I'm in WSL all the time. I have a question though, does poetry install install all the dependencies required for wps? Because I had file-not-found errors for each of the autopep8 import-linter and other steps of the Makefile which i had resolved by pip3 install ing all the dependencies. Maybe whatever I install in a virtual environment gets reset the next time I run poetry shell ?

@sobolevn
Copy link
Member

sobolevn commented Oct 29, 2020

does poetry install install all the dependencies required for wps?

Yes, it does. We have a CI to ensure it 🙂

Maybe whatever I install in a virtual environment gets reset the next time I run poetry shell ?

It sould not. But, I can clearly see that your env has some problem. Glad, that you have solved them!

@Ajax-Light
Copy link

Hey @sobolevn, quick update, I'm still learning about the ast module and going thought the developer documentation in my free time. I need a couple of days to post a fix, feel free to unassign me if its too long. Cheers! 👍

@sobolevn
Copy link
Member

@Ajax-Light no worries! We are not in a hurry.

sobolevn added a commit that referenced this issue Feb 6, 2021
sobolevn added a commit that referenced this issue Feb 6, 2021
sobolevn added a commit that referenced this issue Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Entrypoint to the project Hacktoberfest Hactoberfest fun! help wanted Extra attention is needed level:starter Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants