Skip to content

Commit dc5c299

Browse files
docs: Improve "Precise typing of alternative constructors" example
See microsoft/pyright#4001. - TypeVar bounds that contain TypeVars are not well-specified and pyright disallows them - Similarly, TypeVars defined in classes raise weird scoping problems Let's keep the examples portable and avoid relying on mypy-specific features.
1 parent 08c566c commit dc5c299

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

docs/source/more_types.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,9 @@ classes are generic, self-type allows giving them precise signatures:
804804
.. code-block:: python
805805
806806
T = TypeVar('T')
807+
Q = TypeVar('Q', bound='Base[Any]')
807808
808809
class Base(Generic[T]):
809-
Q = TypeVar('Q', bound='Base[T]')
810-
811810
def __init__(self, item: T) -> None:
812811
self.item = item
813812

0 commit comments

Comments
 (0)