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

fix: exempt TypedDict from typing_extensions #9167

Merged
merged 2 commits into from
Oct 22, 2023
Merged
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
8 changes: 7 additions & 1 deletion pylint/checkers/design_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
DATACLASS_IMPORT = "dataclasses"
TYPING_NAMEDTUPLE = "typing.NamedTuple"
TYPING_TYPEDDICT = "typing.TypedDict"
TYPING_EXTENSIONS_TYPEDDICT = "typing_extensions.TypedDict"

# Set of stdlib classes to ignore when calculating number of ancestors
STDLIB_CLASSES_IGNORE_ANCESTOR = frozenset(
Expand Down Expand Up @@ -168,6 +169,7 @@
"typing.Sized",
TYPING_NAMEDTUPLE,
TYPING_TYPEDDICT,
TYPING_EXTENSIONS_TYPEDDICT,
)
)

Expand All @@ -179,7 +181,11 @@ def _is_exempt_from_public_methods(node: astroid.ClassDef) -> bool:
for ancestor in node.ancestors():
if is_enum(ancestor):
return True
if ancestor.qname() in (TYPING_NAMEDTUPLE, TYPING_TYPEDDICT):
if ancestor.qname() in (
TYPING_NAMEDTUPLE,
TYPING_TYPEDDICT,
TYPING_EXTENSIONS_TYPEDDICT,
):
return True

# Or if it's a dataclass
Expand Down