-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: no-member
for ParamSpec
under Python 3.12
#9401
Comments
Hi @lord-haffi, would you mind updating the snippet to include imports and assignments of P and T? Thanks! |
Thanks for the report! This diff to astroid should fix it: diff --git a/astroid/brain/brain_typing.py b/astroid/brain/brain_typing.py
index ea496440..20276b6c 100644
--- a/astroid/brain/brain_typing.py
+++ b/astroid/brain/brain_typing.py
@@ -437,7 +437,13 @@ def _typing_transform():
class Generic:
@classmethod
def __class_getitem__(cls, item): return cls
- class ParamSpec: ...
+ class ParamSpec:
+ @property
+ def args(self):
+ return ParamSpecArgs(self)
+ @property
+ def kwargs(self):
+ return ParamSpecKwargs(self)
class ParamSpecArgs: ...
class ParamSpecKwargs: ...
class TypeAlias: ...
This is exactly pylint's issue. In 3.12 CPython decided to C-accelerate the typing module, and that hosed a lot of pylint's ability to inspect typing classes. I stubbed out the bare minimum in pylint-dev/astroid@f2120db, but there's a lot missing. |
@jacobtylerwalls Is this the same issue as with |
I don't know what happened with collections. I'd love to know of a better solution for this, and this sounds like it. |
See pylint-dev/astroid#1512 and related PRs. We might be able to come up with a similar fix here. |
Sure! Well, you already figured it out but for the sake of completeness I edited my post. Thanks! |
@DanielNoord it's actually not as bad as the collections issue. I looked into the reason that I stubbed out the typing module. It turns out it was really just to pass about a dozen or so cases in astroid that depend on being able to infer the bases of a class using subscript syntax. It doesn't yet work with the new PEP 695 syntax. We should fix it in a minor release when someone volunteers. In the meantime, I think my stopgap is good for a patch release. I'll open an astroid issue with my finding. |
Opened pylint-dev/astroid#2370 for the real fix. Will prepare a patch with the band-aid. |
Bug description
A piece of code which worked fine for Python 3.11 (pylint v3.0.3 doesn't report anything here). But with the upgrade to 3.12
pylint
suddenly doesn't know the members ofParamSpec
anymore. I know that the generic typing got reworked in 3.12, maybe I'm doing something wrong. I took a quick look at thetyping
package in 3.12 and couldn't find any declaration ofParamSpec
so it might be more a problem of the Python 3.12 release.Configuration
No response
Command used
Pylint output
Expected behavior
No false-positive here.
mypy
has no complains about this code and the tests work fine under Python 3.12 as well.Pylint version
OS / Environment
Windows 11
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: