wemake-services/wemake-python-styleguide

False positive WPS441

Xoriun opened this issue · 0 comments

Xoriun commented

What's wrong

With the following code, I get an WPS441 on the last use of test:

for test in (1, 2):
    print(test)
test = 5
print(test)

How it should be

Since test was redefined after the loop, where it was used as a loop variable, it now doesn't depend on whatever happened in the loop and therefore contains what I expect it to.
Therefore it shouldn't raise a WPS441 in this situation, imo.

Flake8 version and plugins

{
"platform": {
"python_implementation": "CPython",
"python_version": "3.11.6",
"system": "Windows"
},
"plugins": [
{
"plugin": "darglint",
"version": "1.8.1"
},
{
"plugin": "flake8-bandit",
"version": "4.1.1"
},
{
"plugin": "flake8-broken-line",
"version": "1.0.0"
},
{
"plugin": "flake8-bugbear",
"version": "24.1.16"
},
{
"plugin": "flake8-builtins",
"version": "2.2.0"
},
{
"plugin": "flake8-commas",
"version": "2.1.0"
},
{
"plugin": "flake8-comprehensions",
"version": "3.14.0"
},
{
"plugin": "flake8-debugger",
"version": "4.1.2"
},
{
"plugin": "flake8-docstrings",
"version": "1.7.0"
},
{
"plugin": "flake8-eradicate",
"version": "1.5.0"
},
{
"plugin": "flake8-isort",
"version": "6.1.1"
},
{
"plugin": "flake8-pie",
"version": "0.16.0"
},
{
"plugin": "flake8-quotes",
"version": "3.3.2"
},
{
"plugin": "flake8-rst-docstrings",
"version": "0.3.0"
},
{
"plugin": "flake8-string-format",
"version": "0.3.0"
},
{
"plugin": "mccabe",
"version": "0.7.0"
},
{
"plugin": "pep8-naming",
"version": "0.13.3"
},
{
"plugin": "pycodestyle",
"version": "2.11.1"
},
{
"plugin": "pyflakes",
"version": "3.2.0"
},
{
"plugin": "wemake-python-styleguide",
"version": "0.18.0"
}
],
"version": "7.0.0"
}

pip information

pip 23.3.2 from C:\Users\Praktikant\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip (python 3.11)
aiofiles==23.2.1
alabaster==0.7.16
altgraph==0.17.4
anyio==4.2.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
astor==0.8.1
astroid==3.0.2
asttokens==2.4.1
async-lru==2.0.4
attrs==23.2.0
auto-py-to-exe==2.42.0
Babel==2.14.0
bandit==1.7.6
beautifulsoup4==4.12.2
bleach==6.1.0
bottle==0.12.25
bottle-websocket==0.2.9
certifi==2023.11.17
cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
ci-info==0.3.0
click==8.1.7
colorama==0.4.6
comm==0.2.1
configobj==5.0.8
configparser==6.0.0
contourpy==1.2.0
cycler==0.12.1
darglint==1.8.1
debugpy==1.8.0
decorator==5.1.1
defusedxml==0.7.1
dill==0.3.7
docutils==0.20.1
Eel==0.16.0
eradicate==2.3.0
etelemetry==0.3.1
executing==2.0.1
fastjsonschema==2.19.1
filelock==3.13.1
fitz==0.0.1.dev2
flake8==7.0.0
flake8-bandit==4.1.1
flake8-broken-line==1.0.0
flake8-bugbear==24.1.16
flake8-builtins==2.2.0
flake8-commas==2.1.0
flake8-comprehensions==3.14.0
flake8-debugger==4.1.2
flake8-docstrings==1.7.0
flake8-eradicate==1.5.0
flake8-isort==6.1.1
flake8-pie==0.16.0
flake8-quotes==3.3.2
flake8-rst-docstrings==0.3.0
flake8-string-format==0.3.0
fonttools==4.47.2
fqdn==1.5.1
frontend==0.0.3
future==0.18.3
gevent==23.9.1
gevent-websocket==0.10.1
gitdb==4.0.11
GitPython==3.1.41
greenlet==3.0.3
gudhi==3.9.0
h11==0.14.0
httplib2==0.22.0
idna==3.6
imagesize==1.4.1
iniconfig==2.0.0
ipykernel==6.29.0
ipympl==0.9.3
ipython==8.20.0
ipython-genutils==0.2.0
ipywidgets==8.1.1
iso8601==2.1.0
isodate==0.6.1
isoduration==20.11.0
isort==5.13.2
itsdangerous==2.1.2
jedi==0.19.1
Jinja2==3.1.3
json5==0.9.14
jsonpointer==2.4
jsonschema==4.21.0
jsonschema-specifications==2023.12.1
jupyter-events==0.9.0
jupyter-lsp==2.2.1
jupyter_client==8.6.0
jupyter_core==5.7.1
jupyter_server==2.12.5
jupyter_server_terminals==0.5.1
jupyterlab==4.0.10
jupyterlab-widgets==3.0.9
jupyterlab_pygments==0.3.0
jupyterlab_server==2.25.2
kiwisolver==1.4.5
line-profiler==4.1.2
looseversion==1.3.0
lxml==5.1.0
markdown-it-py==3.0.0
MarkupSafe==2.1.3
matplotlib==3.8.2
matplotlib-inline==0.1.6
mccabe==0.7.0
mdurl==0.1.2
mistune==3.0.2
nbclient==0.9.0
nbconvert==7.14.2
nbformat==5.9.2
nest-asyncio==1.5.9
networkx==3.2.1
nibabel==5.2.0
nipype==1.8.6
notebook==7.0.6
notebook_shim==0.2.3
numpy==1.26.3
overrides==7.4.0
packaging==23.2
pandas==2.1.4
pandocfilters==1.5.0
parso==0.8.3
pathlib==1.0.1
pbr==6.0.0
pefile==2023.2.7
pep8-naming==0.13.3
pillow==10.2.0
platformdirs==4.1.0
plotly==5.18.0
pluggy==1.3.0
prometheus-client==0.19.0
prompt-toolkit==3.0.43
prov==2.0.0
psutil==5.9.7
pure-eval==0.2.2
pycodestyle==2.11.1
pycparser==2.21
pydocstyle==6.3.0
pydot==2.0.0
pyflakes==3.2.0
Pygments==2.17.2
pyinstaller==6.3.0
pyinstaller-hooks-contrib==2023.12
pylint==3.0.3
PyMuPDF==1.23.15
PyMuPDFb==1.23.9
pyparsing==3.1.1
pyserial==3.5
PySimpleGUI==4.60.5
PySimpleGUIWeb==0.39.0
pytest==7.4.4
python-dateutil==2.8.2
python-json-logger==2.0.7
pytz==2023.3.post1
pywin32==306
pywin32-ctypes==0.2.2
pywinpty==2.0.12
pyxnat==1.6
PyYAML==6.0.1
pyzmq==25.1.2
rdflib==7.0.0
referencing==0.32.1
remi==2022.7.27
reportlab==4.0.9
requests==2.31.0
restructuredtext-lint==1.4.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.7.0
rpds-py==0.17.1
scipy==1.11.4
Send2Trash==1.8.2
simplejson==3.19.2
six==1.16.0
smmap==5.0.1
sniffio==1.3.0
snowballstemmer==2.2.0
soupsieve==2.5
Sphinx==7.2.6
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
stack-data==0.6.3
starlette==0.35.1
stevedore==5.1.0
tenacity==8.2.3
terminado==0.18.0
tinycss2==1.2.1
tomlkit==0.12.3
tornado==6.4
traitlets==5.14.1
traits==6.4.3
types-python-dateutil==2.8.19.20240106
typing_extensions==4.9.0
tzdata==2023.4
uri-template==1.3.0
urllib3==2.1.0
uvicorn==0.26.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.7.0
wemake-python-styleguide==0.18.0
whichcraft==0.6.1
widgetsnbextension==4.0.9
wxPython==4.2.1
zope.event==5.0
zope.interface==6.1

OS information

Windows 10