This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(x, y) -> None: | |
| z: str = 0 | |
| reveal_type((x, y)) | |
| def g(x: int, y: str): | |
| z: str = 0 | |
| reveal_type((x, y)) | |
| def h(x, y): | |
| z: str = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import typing | |
| class P(typing.Protocol): | |
| def foo(self, a: int) -> None: ... | |
| class C: | |
| def foo(self, *args: int) -> None: pass | |
| def f(o: P) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import typing | |
| class P(typing.Protocol): | |
| def foo(self, a: int) -> None: ... | |
| class C: | |
| def foo(self, *args: int) -> None: pass | |
| def f(o: P) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import typing | |
| class P(typing.Protocol): | |
| def foo(self, a: int) -> None: ... | |
| class C: | |
| def foo(self, *args: int) -> None: pass | |
| def f(o: P) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Iterator | |
| def fib(n: int) -> Iterator[int]: | |
| a, b = 0, 1 | |
| while a < n: | |
| yield a | |
| a, b = b, a + b | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from enum import Enum | |
| from typing import assert_never | |
| class A(Enum): | |
| A0 = "0" | |
| A1 = "1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type atype = ().__class__.__class__[().__class__.__class__[().__class__.__mro__[-1]]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import TypeVar, Generic | |
| from collections.abc import Callable | |
| BaseExcT_co = TypeVar("BaseExcT_co", bound=BaseException, covariant=True) | |
| BaseExcT_co_default = TypeVar( | |
| "BaseExcT_co_default", bound=BaseException, covariant=True, default=BaseException | |
| ) | |
| class RaisesExc(Generic[BaseExcT_co_default]): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Iterator | |
| def fib(n: int) -> Iterator[int]: | |
| a, b = 0, 1 | |
| while a < n: | |
| yield a | |
| a, b = b, a + b | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| reveal_type(1) |
NewerOlder