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 Meta(type): | |
def m(cls) -> int: | |
return 0 | |
def __add__(cls, other) -> int: | |
return 0 | |
class A(metaclass=Meta): | |
@classmethod | |
def m(cls) -> 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 Callable, Coroutine | |
from logging import getLogger | |
logger = getLogger(__name__) | |
class StatsD: | |
def increment(self, metric: str) -> 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 dataclasses | |
import pymock | |
@dataclasses.dataclass(frozen=True) | |
class F: | |
a: int = 4 | |
b: float = 1/a | |
@dataclasses.dataclass(frozen=True) | |
class G: |
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 itertools | |
import typing as t | |
from collections import abc | |
from pathlib import Path | |
class PackageSpec(t.NamedTuple): | |
package_name: str | |
locked_ver: str | 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
class MyClass: | |
_my_field: int | |
def __init__(self) -> None: | |
pass | |
def foo(self) -> int: | |
return self._my_field # Используется не инициализированной. | |
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 | |
def non_optional[T](value: T|None)->T: | |
assert value is not None | |
return value | |
def f(x: int|None): | |
reveal_type(x) | |
y = non_optional(x) | |
reveal_type(y) |
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
options: list[tuple[int, *tuple[str, ...]]] = [(1, 'a'), (2, 'b', 'c')] | |
for i, *s in options: | |
print(hex(i), '_'.join(s)) |
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
for i, s in [(1, ('a',)), (2, ('b', 'c'))]: | |
print(hex(i), '_'.join(s)) |
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
options: list[tuple[int, *tuple[str, ...]]] = [(1, 'a'), (2, 'b', 'c')] | |
for i, *s in options: | |
print(hex(i), '_'.join(s)) |
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
for i, *s in [(1, 'a'), (2, 'b', 'c')]: | |
print(hex(i), '_'.join(s)) |
NewerOlder