You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a follow up to #1927, #2607, and #4072. In Python 3.9, TypedDict was changed from a class to a function with metaclass magic. This change caused worse problems initially (fixed by #4072), but now pylint gives a warning about too few public methods when subclassing TypedDict to create a new type as suggested in the documentation (https://docs.python.org/3/library/typing.html#typing.TypedDict). A work around is to use one of the alternate TypedDict syntax forms in which TypedDict is used as a function instead of a class.
Steps to reproduce
Given a file a.py:
"Demo"importtypingclassCoordinate(typing.TypedDict):
"This is my type"x: floaty: float
Current behavior
Result of pylint a.py:
************* Module test
test.py:5:0: R0903: Too few public methods (0/2) (too-few-public-methods)
------------------------------------------------------------------
Your code has been rated at 7.50/10 (previous run: 7.50/10, +0.00)
Expected behavior
No warnings.
pylint --version output
Result of pylint --version output:
pylint 2.7.2
astroid 2.5.1
Python 3.9.2
The text was updated successfully, but these errors were encountered:
Yeah, with pylint-dev/astroid#915 TypedDicts are now inferred as classes and thus all default class checks do apply. It might indeed make sense to disable too-few-public-methods if the class inherits from TypedDict.
This is a follow up to #1927, #2607, and #4072. In Python 3.9, TypedDict was changed from a class to a function with metaclass magic. This change caused worse problems initially (fixed by #4072), but now pylint gives a warning about too few public methods when subclassing TypedDict to create a new type as suggested in the documentation (https://docs.python.org/3/library/typing.html#typing.TypedDict). A work around is to use one of the alternate TypedDict syntax forms in which TypedDict is used as a function instead of a class.
Steps to reproduce
Given a file
a.py
:Current behavior
Result of
pylint a.py
:Expected behavior
No warnings.
pylint --version output
Result of
pylint --version
output:The text was updated successfully, but these errors were encountered: