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

WPS610 (async magic) false positive on __aiter__ #2399

Closed
Sxderp opened this issue Apr 20, 2022 · 1 comment · Fixed by #2400
Closed

WPS610 (async magic) false positive on __aiter__ #2399

Sxderp opened this issue Apr 20, 2022 · 1 comment · Fixed by #2400
Labels
bug Something isn't working good first issue Entrypoint to the project help wanted Extra attention is needed level:starter Good for newcomers

Comments

@Sxderp
Copy link
Contributor

Sxderp commented Apr 20, 2022

What's wrong

In Python 3.7+ a class __aiter__ must return an async iterator object (an object that implements __anext__). An async generator (an async function with yield) is considered an async iterator object.

The following is valid and should not be flagged as an incorrect async definition.

class Ex(object):
    async def __aiter__(self):
        count = 0
        while count < 50:
            count += 1
            yield count

The following is invalid and should be flagged as incorrect (it'll also throw a type error or somesuch if actually used in async for).

class Ex(object):
    async def __aiter__(self):
        count = 0
        while count < 50:
            count += 1

How it should be

See above. Don't throw an error.

Flake8 version and plugins

{
"dependencies": [],
"platform": {
"python_implementation": "CPython",
"python_version": "3.8.10",
"system": "Linux"
},
"plugins": [
{
"is_local": false,
"plugin": "flake8-bandit",
"version": "3.0.0"
},
{
"is_local": false,
"plugin": "flake8-broken-line",
"version": "0.4.0"
},
{
"is_local": false,
"plugin": "flake8-bugbear",
"version": "22.3.23"
},
{
"is_local": false,
"plugin": "flake8-class-attributes-order",
"version": "0.1.3"
},
{
"is_local": false,
"plugin": "flake8-comprehensions",
"version": "3.8.0"
},
{
"is_local": false,
"plugin": "flake8-darglint",
"version": "1.8.1"
},
{
"is_local": false,
"plugin": "flake8-debugger",
"version": "4.0.0"
},
{
"is_local": false,
"plugin": "flake8-docstrings",
"version": "1.6.0, pydocstyle: 6.1.1"
},
{
"is_local": false,
"plugin": "flake8-eradicate",
"version": "1.2.0"
},
{
"is_local": false,
"plugin": "flake8-string-format",
"version": "0.3.0"
},
{
"is_local": false,
"plugin": "flake8_commas",
"version": "2.1.0"
},
{
"is_local": false,
"plugin": "flake8_isort",
"version": "4.1.1"
},
{
"is_local": false,
"plugin": "flake8_quotes",
"version": "3.3.1"
},
{
"is_local": false,
"plugin": "mccabe",
"version": "0.6.1"
},
{
"is_local": false,
"plugin": "naming",
"version": "0.12.1"
},
{
"is_local": false,
"plugin": "pycodestyle",
"version": "2.8.0"
},
{
"is_local": false,
"plugin": "pyflakes",
"version": "2.4.0"
},
{
"is_local": false,
"plugin": "pylint",
"version": "0.0.0"
},
{
"is_local": false,
"plugin": "rst-docstrings",
"version": "0.2.5"
},
{
"is_local": false,
"plugin": "wemake_python_styleguide",
"version": "0.16.1"
}
],
"version": "4.0.1"
}

pip information

adblockparser==0.7
amkv==0.1.2
anyio==3.5.0
appdirs==1.4.3
apturl==0.5.2
astor==0.8.1
async-generator==1.10
async-timeout==4.0.2
asyncache==0.1.1
atomicwrites==1.1.5
attrs==19.3.0
Automat==0.8.0
bandit==1.7.4
bcrypt==3.1.7
beautifulsoup4==4.11.1
blinker==1.4
Brlapi==0.7.0
Brotli==1.0.9
cachetools==5.0.0
certifi==2019.11.28
cffi==1.14.0
chardet==4.0.0
charset-normalizer==2.0.12
Click==7.0
colorama==0.4.3
command-not-found==0.3
constantly==15.1.0
crit==0.0.1
croniter==1.3.4
cryptography==2.8
cupshelpers==1.0
cycler==0.10.0
Cython==0.29.14
darglint==1.8.1
dblatex===0.3.11py3
dbus-python==1.2.16
decorator==4.4.2
defer==1.0.6
Deprecated==1.2.13
distlib==0.3.0
distro==1.4.0
distro-info===0.23ubuntu1
dnspython==1.16.0
docutils==0.18.1
EditorConfig==0.12.2
entrypoints==0.3
eradicate==2.1.0
et-xmlfile==1.0.1
fasteners==0.14.1
ffmpeg-normalize==1.22.9
ffmpeg-progress-yield==0.2.0
filelock==3.0.12
flake8==4.0.1
flake8-bandit==3.0.0
flake8-broken-line==0.4.0
flake8-bugbear==22.3.23
flake8-class-attributes-order==0.1.3
flake8-commas==2.1.0
flake8-comprehensions==3.8.0
flake8-debugger==4.0.0
flake8-docstrings==1.6.0
flake8-eradicate==1.2.0
flake8-isort==4.1.1
flake8-polyfill==1.0.2
flake8-quotes==3.3.1
flake8-rst-docstrings==0.2.5
flake8-string-format==0.3.0
flakeheaven==0.11.1
funcparserlib==0.3.6
future==0.18.2
gevent==21.12.0
gil-load==0.4.2
gitdb==4.0.9
gitdb2==2.0.6
GitPython==3.1.27
gpg===1.13.1-unknown
graphviz==0.16
greenlet==1.1.2
gssapi==1.6.1
h11==0.12.0
h2==4.1.0
h5py==2.10.0
hpack==4.0.0
html5-parser==0.4.10
html5lib==1.0.1
httpcore==0.14.7
httplib2==0.14.0
httpx==0.22.0
hypercorn==0.13.2
hyperframe==6.0.1
hyperlink==19.0.0
idna==2.8
imageio==2.4.1
importlib-metadata==1.5.0
incremental==21.3.0
iotop==0.6
isc==2.0
isort==5.10.1
jdcal==1.0
Jinja2==2.10.1
jsbeautifier==1.10.3
Keras==2.2.4
Keras-Applications==1.0.6
Keras-Preprocessing==1.0.5
keyring==18.0.1
kiwisolver==1.0.1
language-selector==0.1
launchpadlib==1.10.13
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
linecache2==1.0.0
lockfile==0.12.2
louis==3.12.0
lxml==4.5.0
macaroonbakery==1.3.1
Mako==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.0
matplotlib==3.1.2
mccabe==0.6.1
memory-analyzer==0.1.2
meson==0.53.2
mock==3.0.5
monotonic==1.5
more-itertools==4.2.0
mpi4py==3.0.3
msgpack==0.6.2
multidict==6.0.2
mutagen==1.45.1
nest-asyncio==1.5.5
netaddr==0.7.19
netifaces==0.10.4
networkx==2.8
nftables==0.1
nose==1.3.7
numexpr==2.7.1
numpy==1.22.3
oauthlib==3.1.0
objgraph==3.5.0
olefile==0.46
opencv-python==4.5.5.64
openpyxl==3.0.3
outcome==1.1.0
packaging==21.3
pandas==0.25.3
parameterized==0.7.0
paramiko==2.6.0
patsy==0.5.1
pbr==5.4.5
peewee==3.14.10
pep8-naming==0.12.1
pexpect==4.6.0
Pillow==7.0.0
pluggy==0.13.0
ply==3.11
prettytable==2.1.0
priority==1.3.0
protobuf==3.6.1
psutil==5.5.1
py==1.8.1
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycairo==1.16.2
pycodestyle==2.8.0
pycparser==2.19
pycrypto==2.6.1
pycryptodomex==3.14.1
pycups==1.9.73
pydocstyle==6.1.1
pydot==1.4.1
pyflakes==2.4.0
Pygments==2.11.2
PyGObject==3.36.0
pygpu==0.7.6
PyHamcrest==1.9.0
PyJWT==1.7.1
pymacaroons==0.13.0
Pympler==0.9
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyparsing==3.0.8
PyQt5==5.14.1
PyQtWebEngine==5.14.0
pyRFC3339==1.1
pytest==4.6.9
python-apt==2.0.0+ubuntu0.20.4.6
python-augeas==0.5.0
python-dateutil==2.7.3
python-debian===0.1.36ubuntu1
python-ldap==3.2.0
python-libtorrent==1.1.13
python-multipart==0.0.5
python-yubico==1.3.3
pytz==2019.3
pyusb==1.0.2
PyWavelets==1.3.0
pyxdg==0.26
PyYAML==5.3.1
pyzmq==18.1.1
qrtools==2.0
qt5reactor==0.6
QtPy==1.9.0
redis==4.2.2
reportlab==3.5.34
requests==2.27.1
requests-unixsocket==0.2.0
restructuredtext-lint==1.4.0
rfc3986==1.3.2
salt==3000.2
scikit-image==0.19.2
scipy==1.8.0
seaborn==0.10.0
SecretStorage==2.3.1
selinux==3.0
service-identity==18.1.0
simplejson==3.16.0
sip==4.19.21
six==1.14.0
slip==0.6.5
slip.dbus==0.6.5
smmap==5.0.0
smmap2==2.0.5
sniffio==1.1.0
snowballstemmer==2.0.0
sortedcontainers==2.1.0
soupsieve==1.9.5
splash==3.5
ssh-import-id==5.10
starlette==0.19.0
stevedore==1.32.0
systemd-python==234
tables==3.6.1
testfixtures==6.10.1
testresources==2.0.0
Theano==1.0.4
tifffile==2022.4.8
toml==0.10.0
tqdm==4.64.0
traceback2==1.4.0
trio==0.20.0
Twisted==22.4.0
typing-extensions==4.2.0
ubuntu-advantage-tools==27.4
ubuntu-drivers-common==0.0.0
unattended-upgrades==0.1
unittest2==1.1.0
urllib3==1.26.9
usb-creator==0.3.7
virtualenv==20.0.17
wadllib==1.3.3
wcwidth==0.1.8
webencodings==0.5.1
websockets==10.3
wemake-python-styleguide==0.16.1
Werkzeug==2.1.1
wrapt==1.14.0
wsproto==1.1.0
xdis==6.0.3
xkit==0.0.0
xlrd==1.1.0
xlwt==1.3.0
xvfbwrapper==0.2.9
yarl==1.7.2
youtube-dl==2021.12.17
yt-dlp==2022.4.8
zipp==1.0.0
zope.event==4.5.0
zope.interface==4.7.1

OS information

Ubuntu 20.04

@Sxderp Sxderp added the bug Something isn't working label Apr 20, 2022
@sobolevn
Copy link
Member

PR is welcome!

@sobolevn sobolevn added help wanted Extra attention is needed level:starter Good for newcomers good first issue Entrypoint to the project labels Jul 17, 2022
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 help wanted Extra attention is needed level:starter Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants