-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Regression: Value 'Collection' is unsubscriptable #2377
Comments
In fact, this seems to be a Python 3.6 specific issue.
There's no issue for 3.7, so I'm not sure if this should be considered a regression |
Hi, thanks for the report. I can also reproduce this bug. |
This issue also happens for me with the following versions:
|
Also seeing this with
|
Looking at the code of I think I ended up using this workaround: from typing import TYPE_CHECKING, Collection
if not TYPE_CHECKING:
# Work around PyLint issue on Python 3.6.
# https://github.com/PyCQA/pylint/issues/2377
from typing import Sequence # pylint: disable=ungrouped-imports
Collection = Sequence # pylint: disable=invalid-name |
Also occurs on python 3.5:
|
I'm working on adding pylint (+mypy) to all of QEMU's CI for our test infrastructure. We use Python 3.6 as our minimum viable python version for test infrastructure, so we are encountering this issue. It appears to be an issue on all 2.x.x pylint versions against Python 3.6.10. For now, my workaround will likely be just using |
Still hurts on
|
This issue seems to be fixed when testing with the latest pylint version. Closing it. |
… Collection[int] as this is broken (pylint-dev/pylint#2377).
Pylint under 3.6 does not believe that Collection is subscriptable at runtime. It is, making this a Pylint bug. pylint-dev/pylint#2377 They closed it as fixed, but that doesn't seem to be true as of Pylint 2.13.9, the latest version you can install under Python 3.6. 2.13.9 was released 2022-05-13, about seven months after the bug was closed. The least-annoying fix here is to just use the concret type. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20230215000011.1725012-4-jsnow@redhat.com> [Dumbed down from Sequence[str] to List[str], commit message adjusted] Reviewed-by: Markus Armbruster <armbru@redhat.com>
Steps to reproduce
Run pylint on this file
Current behavior
repro.py:3:16: E1136: Value 'Collection' is unsubscriptable (unsubscriptable-object)
Expected behavior
No errors.
pylint --version output
Breaks for 2.1.0:
Does not break for 1.9.2:
If there is a configuration workaround for this (except for disabling
unsubscriptable-object
globally) that would be nice, but neitherignored-modules=typing
orignored-classes=Collection
worked for me.The text was updated successfully, but these errors were encountered: