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

Add members to ParamSpec stub #2371

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ What's New in astroid 3.0.3?
============================
Release date: TBA

* Fix ``no-member`` false positives for ``args`` and ``kwargs`` on ``ParamSpec`` under Python 3.12.

Closes pylint-dev/pylint#9401


What's New in astroid 3.0.2?
============================
Expand Down
8 changes: 7 additions & 1 deletion astroid/brain/brain_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
13 changes: 13 additions & 0 deletions tests/brain/test_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,19 @@ def test_typing_no_duplicates_2(self):
)
assert len(node.inferred()) == 1

@test_utils.require_version(minver="3.10")
def test_typing_param_spec(self):
node = builder.extract_node(
"""
from typing import ParamSpec

P = ParamSpec("P")
"""
)
inferred = next(node.targets[0].infer())
assert next(inferred.igetattr("args")) is not None
assert next(inferred.igetattr("kwargs")) is not None

def test_collections_generic_alias_slots(self):
"""Test slots for a class which is a subclass of a generic alias type."""
node = builder.extract_node(
Expand Down
Loading