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 dataclasses import dataclass | |
| @dataclass | |
| class Network: | |
| cidr: str | |
| @dataclass | |
| class Subnet: | |
| network: 'NetworkQ' | |
| cidr: str |
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, Generator | |
| from types import coroutine | |
| T = TypeVar("T", str, bytes) | |
| async def process(data: T) -> T: | |
| return data | |
| @coroutine | |
| def process2(data: T) -> Generator[T, None, T]: |
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, Generator | |
| from types import coroutine | |
| T = TypeVar("T", str, bytes) | |
| async def process(data: T) -> T: | |
| return data | |
| @coroutine | |
| def process2(data: T) -> Generator[T, None, T]: |
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(whatever) -> int: | |
| return 42 | |
| @f | |
| class Foo: ... | |
| reveal_type(Foo) |
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 Pattern, Match | |
| import re | |
| reveal_type(re.compile("[abc]*")) | |
| reveal_type(re.match(my_pattern, "abbcab")) |
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 Pattern, Match | |
| import re | |
| reveal_type(re.compile("[abc]*")) | |
| reveal_type(re.match(my_pattern, "abbcab")) |
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 pathlib import Path | |
| class MyClass: | |
| def __init__(self, path: Path | None) -> None: | |
| self.path = path | |
| def test(a: MyClass, b: MyClass): | |
| if a.path is 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 Callable, ParamSpec | |
| P = ParamSpec('P') | |
| DefaultP = ParamSpec('DefaultP', default=(int, str)) # Error |
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: | |
| import math | |
| def __new__(cls) -> "A": | |
| reveal_type(cls.math.pi) # N: Revealed type is "Any" | |
| return cls() | |
| def pos_or_named_self(self) -> None: | |
| reveal_type(self.math.pi) # N: Revealed type is "builtins.float" |
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: | |
| import math | |
| def __new__(cls) -> "A": | |
| reveal_type(cls.math.pi) # N: Revealed type is "types.ModuleType" | |
| return cls() | |
| def pos_or_named_self(self) -> None: | |
| reveal_type(self.math.pi) # N: Revealed type is "types.ModuleType" |
NewerOlder