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
If __init__ has no annotation, it's likely that some attributes have implicit Any types, which seriously compromises type checking. This is a common mistake. Example where this is a problem:
classC:
def__init__(self):
self.a= [] # Inferred type for 'a' is Any, since no annotationdefmethod(self) ->str:
returnself.a# No error, since Any is compatible with str
Add an optional check to generate an error if __init__ has no type annotation but some attribute or method defined in the class body has a type annotation. The check would be enabled using --enable-error-code <code>.
Only look at definitions within the class body and ignore inherited __init__ and other inherited members.
This can be a little tricky to support in the daemon, since we'll need to add a dependency from every attribute to __init__ when the error code is enabled, if __init__ has no annotation (assuming this property is checked as part of checking __init__), and we need to keep track of whether each attribute has an annotation or not -- I'm not sure if the daemon keeps track of this or not.
The text was updated successfully, but these errors were encountered:
If
__init__
has no annotation, it's likely that some attributes have implicitAny
types, which seriously compromises type checking. This is a common mistake. Example where this is a problem:Add an optional check to generate an error if
__init__
has no type annotation but some attribute or method defined in the class body has a type annotation. The check would be enabled using--enable-error-code <code>
.Only look at definitions within the class body and ignore inherited
__init__
and other inherited members.This can be a little tricky to support in the daemon, since we'll need to add a dependency from every attribute to
__init__
when the error code is enabled, if__init__
has no annotation (assuming this property is checked as part of checking__init__
), and we need to keep track of whether each attribute has an annotation or not -- I'm not sure if the daemon keeps track of this or not.The text was updated successfully, but these errors were encountered: