Spec change: Do not require an error for a generic class attribute
Discussions on Python.org
Spec change: Do not require an error for a generic class attribute
The conformance suite currently requires an error for this code: from typing import Any, TypeVar, Generic, assert_type T = TypeVar("T") class Node(Generic[T]): label: T def __init__(self, label: T | None = None) -> None: if label is not None: self.label = label n1: Node[int] = Node() type(n1).label # E While that error is correct in this specific case, it’s difficult to justify it in general: the attribute may be defined on a child class, for example. Curre...
0 comments
No comments yet.