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 Iterato | |
| 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
| from typing import reveal_type | |
| text = "some\nstuff" | |
| version, desc, *_ = [*text.split(sep="\n", maxsplit=1), None, None] | |
| reveal_type(version) | |
| reveal_type(desc) |
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, reveal_type | |
| from enum import Enum | |
| _T = TypeVar("_T") | |
| def construct_from_string(key: str, enum_type: Callable[[str], _T]) -> _T: | |
| return enum_type(key.lower()) | |
| class Color(Enum): |
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 pathlib | |
| test = pathlib.Path("test/path/foo.py") | |
| test.suffix == "foo.py" |
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
| """Module used to test Ruff.""" | |
| import logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| class Sample: | |
| """Test class.""" |
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 hello(x: str) -> str: | |
| return f"hello: {x}" | |
| def add(a: float, b: float) -> int: | |
| return int(a + b) | |
| hello("james") | |
| add(5.3, 50) |
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
| a: tuple[str, ...] | |
| b: tuple[str, *tuple[str, ...]] | |
| b = ("first", *a) # ok | |
| b = (*a, "last") # Incompatible types in assignment (expression has type "tuple[str, ...]", variable has type "tuple[str, *tuple[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
| foo = 0 | |
| bar = (1, 2) | |
| match foo, *bar: | |
| case _: | |
| pass |
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 subprocess | |
| from typing import Any | |
| def test(command: list[str], kwargs: dict[str, Any]) -> None: | |
| subprocess.run(command, capture_output=True, **kwargs) |
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 opnieuw.test_util import retry_immediately | |
| @retry_immediately() | |
| def foo() -> None: | |
| pass |
NewerOlder