-
When using For example, in: from typing import NamedTuple
class A(NamedTuple):
a: int
a = A(1) Pyright says Why does it want an explicit type annotation for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If your library is marked "py.typed", all public symbols (those that represent the public interface contract for your library) should be annotated. If a symbol is not annotated, its type needs to be inferred by a type checker. Type inference rules are not specified in the typing standards, and they vary by type checker. Inference can also be quite slow depending on the complexity of the expression. For these reasons, it's important for all public symbols to have type annotations. For more details, please refer to this documentation. |
Beta Was this translation helpful? Give feedback.
If your library is marked "py.typed", all public symbols (those that represent the public interface contract for your library) should be annotated. If a symbol is not annotated, its type needs to be inferred by a type checker. Type inference rules are not specified in the typing standards, and they vary by type checker. Inference can also be quite slow depending on the complexity of the expression. For these reasons, it's important for all public symbols to have type annotations.
For more details, please refer to this documentation.