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
| class A: | |
| def __new__(cls) -> int: | |
| return 42 | |
| reveal_type(A()) |
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
| class A: | |
| def go(self) -> None: | |
| pass | |
| class B0: | |
| X: type[A] | None = None | |
| class B(B0): | |
| X = A |
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 Callable, TypeVar | |
| _K = TypeVar("_K") | |
| _V = TypeVar("_V") | |
| class Foo: | |
| pass | |
| class Util: |
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 abc import ABC, abstractmethod | |
| import typing as t | |
| class nmBaseConfig: | |
| ... | |
| class nmLSFConfig(nmBaseConfig): | |
| ... |
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 Callable, TypeVar | |
| _K = TypeVar("_K") | |
| _V = TypeVar("_V") | |
| class Foo: | |
| pass | |
| class Util: |
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 Callable, TypeVar | |
| _K = TypeVar("_K") | |
| _V = TypeVar("_V") | |
| class Foo: | |
| pass | |
| class Util: |
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 ClassVar | |
| from enum import IntEnum | |
| class WithDocReference: | |
| _doc_reference: ClassVar[str] | |
| class MyEnum(WithDocReference, IntEnum): | |
| _doc_reference = "https://www.google.com" | |
| A = 1 | |
| B = 2 |
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 Any, Protocol, assert_type | |
| class WithTuple[*Ts](Protocol): | |
| tup: tuple[*Ts] | |
| def get_tuple[*Ts](e: WithTuple[*Ts]) -> tuple[*Ts]: | |
| return e.tup | |
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 Protocol, runtime_checkable | |
| class P(Protocol): | |
| def f(self) -> None: ... | |
| @runtime_checkable | |
| class RCP(Protocol): | |
| def f(self) -> None: ... |
NewerOlder