Python: All Type Hints Errors In Subclass Constructure Seems Ignored
I have the following code with python type hints It has a bunch of errors. All erros in code are found by mypy but not the errors in constructor of S. Why? I cannot find out what i
Solution 1:
Mypy, by default, will only check functions and methods that have type annotations.
Your subclass's constructor has no annotations and so consequently goes unchecked.
To fix this, modify the signature to read def __init__(self) -> None
.
You can also ask mypy to flag these errors for you using the --disallow-untyped-defs
flag. You can also use the --check-untyped-defs
flag which will make it typecheck all functions, whether or not it has annotations.
Post a Comment for "Python: All Type Hints Errors In Subclass Constructure Seems Ignored"