Skip to content

Commit

Permalink
Add members to ParamSpec stub (#2371)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls authored Feb 4, 2024
1 parent beb9987 commit 32bbc02
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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

0 comments on commit 32bbc02

Please sign in to comment.