Skip to content

Commit

Permalink
docs: Improve "Precise typing of alternative constructors" example
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JelleZijlstra authored Oct 3, 2022
1 parent 08c566c commit dc5c299
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions docs/source/more_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,9 @@ classes are generic, self-type allows giving them precise signatures:
.. code-block:: python
T = TypeVar('T')
Q = TypeVar('Q', bound='Base[Any]')
class Base(Generic[T]):
Q = TypeVar('Q', bound='Base[T]')
def __init__(self, item: T) -> None:
self.item = item
Expand Down

0 comments on commit dc5c299

Please sign in to comment.