file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
code_snippets/mypy/11000-11999/11212.py
Python
from typing import Callable, TypeVar C = TypeVar('C', bound=Callable) def dec(val: None) -> Callable[[C], C]: def wrapper(f): return f return wrapper # E: Cannot determine type of "foo" [has-type] lambda: foo() == 2 @dec(None) def foo() -> int: return 2 foo() == 2 # this one is fine
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11226.py
Python
#!/usr/bin/env python3 from typing import Union, List, Optional def test(a: Union[List[str], str, None] = None) -> Optional[List[str]]: if type(a) == str: a = [a] assert(type(a) != str) return a
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11230.py
Python
from typing import TypeGuard def is_str_list(val: list[object]) -> TypeGuard[list[str]]: return all(isinstance(x, str) for x in val) l1: list[object] = [] l2 = l1 if is_str_list(l1): l2.append(1) impostor: str = l1[0] # SUS ALERT!!!! 😳😳😳😳😳😳😳
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11231.py
Python
from abc import ABC from typing import Generic, Protocol, Set, TypeVar T = TypeVar('T') V = TypeVar('V') class HasData(Generic[T], Protocol): data: T class ReplaceDataMixin(Generic[T]): def replace_data(self: HasData[T], new: T) -> None: self.data = new class HasSet(Generic[V], ABC): def __in...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11238.py
Python
def func(a: object, b: bool) -> None: if b: assert isinstance(a, int) else: assert isinstance(a, str) reveal_type(a) # note: Revealed type is "builtins.object"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11239.py
Python
[mypy-azure-storage-blob] ignore_errors = True
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11252.py
Python
class TestExternal(unittest.TestCase): # TODO: Get this to work on Windows. # (Or don't. It is probably not a good use of time.) @unittest.skipIf(sys.platform.startswith("win"), "rt tests don't work on windows") def test_c_unit_test(self) -> None: """Run C unit tests in a subprocess.""" ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11269.py
Python
from functools import partial from typing import Any, Callable, Union yesno = True thingy: Union[Callable, int] reveal_type(thingy) if yesno: thingy = partial(isinstance, "foo") reveal_type(thingy) else: thingy = 42 reveal_type(thingy)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11282.py
Python
def divide(a: int, b: int) -> int | NoReturn[ZeroDivisionError]: return a // b def main(): res = divide(5, 4) total = 5 + res # mypy will complain here because NoReturn type can't be using with integer print(total) def build_error(error_type: str) -> UnauthorizedApiError | NotFoundApiError | NoRetur...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11288.py
Python
from types import NoneType def foo(a: NoneType): # sus alert, NoneType is a mess in the type realm, you should use `None` or `type[None]` instead. print(isinstance(a, NoneType))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11291.py
Python
from typing import NoReturn # Incompatible types in assignment (expression has type "object", variable has type "Type[NoReturn]") [assignment] foo: type[NoReturn] = NoReturn
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11293.py
Python
# test_case.py from typing import Callable, Iterable, TypeVar, Union _T = TypeVar("_T") def _identity(__: _T) -> _T: return __ # decr: Callable[[_T], _T] = _identity # <-- this approach works DecoratorT = Callable[[_T], _T] decr: DecoratorT = _identity # <-- this causes the false positives below class Result:...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11301.py
Python
import os from typing import AnyStr def thing(value: AnyStr) -> None: with os.scandir(value) as it: for file in it: if file.name.endswith('.xml'): ... thing("hello") #thing(b"world")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11302.py
Python
from types import new_class X = new_class('X', (int,)) def sum_two(a: X, b: X) -> X: return a + b print(sum_two(X(2), X(3)))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11313.py
Python
from typing import Literal literal_t = Literal['a', 'b', 'c'] x: literal_t = 'b' if x == 'a' or x == 'd': ... if x in ('a', 'd'): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11315.py
Python
from typing import Optional, Any class A: ... def anything() -> bool: ... def getA() -> Any: ... x: Optional[A] reveal_type(x) # N: Revealed type is "Optional[A]" if (x := getA()) is not None: reveal_type(x) # N: Revealed type is "Any" reveal_type(x) # N: Revealed type is "Any" x: Optional[A] reveal_type(x)...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11322.py
Python
p/__init__.py p/a.py p/a.py # flags: --namespace-packages
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11330.py
Python
from dataclasses import dataclass @dataclass class Person: age : int name : str def add_non_ext_class_attr(builder: IRBuilder, non_ext: NonExtClassInfo, lvalue: NameExpr, stmt: AssignmentStmt, cdef: Cla...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11336.py
Python
from typing import Final spam: Final[str] = "spam: {eggs}" spam_eggs = spam.format(eggs="EGGS", foo="bar") from typing import Final spam: str = "spam: {eggs}" spam_eggs = spam.format(eggs="EGGS", foo="bar") spam = "spam: {eggs}" spam_eggs = spam.format(eggs="EGGS", foo="bar") from typing import Final spam: Final ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11337.py
Python
from typing import Optional def foo(s: str) -> None: pass def bar(s: Optional[str] = None) -> None: if not s: return d: dict[str, str] = {} s = d.get(s, s) foo(s) # Argument 1 to "foo" has incompatible type "Optional[str]"; expected "str"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11339.py
Python
from typing import Optional a: Optional[int] = 1 b: Optional[int] = 1 if None not in (a, b): print(a + b) # mypy failed if None not in (a, b): print(a + b) # mypy passed if a is not None and b is not None: print(a + b)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11347.py
Python
from typing import Any, Generic, overload, TypeVar, TYPE_CHECKING import numpy as np _CharType = TypeVar("_CharType", np.str_, np.bytes_) class CharArray(Generic[_CharType]): @overload def strip(self: CharArray[np.str_], chars: str = ...) -> CharArray[np.str_]: ... @overload def strip(self: CharArray...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11364.py
Python
from typing import Literal foo: Literal["foo"] = "foo" # error: Non-overlapping equality check (left operand type: "Literal['foo']", right operand type: "Literal['bar']") [comparison-overlap] foo == "bar" bar: Literal[True] # no error bar == False
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11368.py
Python
from enum import Enum class Letter(Enum): A = 'A' B = 'B' @property def shout(self) -> str: s = { self.A: 'Aaaaah', self.B: 'Biiiih', } return s[self] print(Letter.A.shout) print(Letter.B.shout)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11369.py
Python
T = TypeVar("T") R = TypeVar("R") Decorator = Callable[[Callable[..., T]], Callable[..., R]] from typing import * T = TypeVar("T") R = TypeVar("R") Decorator = Callable[[Callable[..., T]], Callable[..., R]] # def to_list() -> Decorator[T, List[T]]: def to_list() -> Callable[[Callable[..., T]], Callable[..., List[T]]...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11379.py
Python
from typing import TypeVar, Union, Generic T1 = TypeVar("T1", int, str, covariant=True) T2 = TypeVar("T2", int, str) class X1(Generic[T1]): def f(self) -> T1: ... class X2(Generic[T2]): def f(self) -> T2: ... def f1(x: X1[int]) -> None: ... def f2(x: X2[int]) -> None: ... f1(X1[int]()) f1(X1[bool]()) f2(X2...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11380.py
Python
from typing import Any, cast MYPY = False def foo(p): # type: (Any) -> int doc = p if MYPY: return cast(int, doc) else: # needs to be in else for MYPY to believe this is reachable return doc def bar(p): # type: (Any) -> int doc = p if MYPY: return cast(int,...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11384.py
Python
vals = [1, 2, 3] operation(vals) print(vals) # What is vals here? def operation(vals: Sequence[int]) -> None: assert isinstance(vals, list) vals += [3, 4, 5]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11388.py
Python
@overload def foo(a: int) -> int: ... @overload def foo(a: str) -> str: ... def foo(a): ... # inferred as (a: int | str) -> int | str
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11391.py
Python
from typing import Union, Generic, TypeVar, overload T = TypeVar("T") class Foo(Generic[T]): pass @overload def expect(pattern: Foo[T]) -> None: ... @overload def expect(pattern: T) -> None: ... def expect(pattern: Union[Foo[T], T]) -> None: return None
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11393.py
Python
from typing import TypeVar T = TypeVar("T") def default(value: T | None, value_if_none: T) -> T: return value_if_none if value is None else value foo: list[str] | None = [] bar = default(foo, []) # expected: list[str] # actual: Revealed type is "builtins.object*" reveal_type(bar)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11397.py
Python
from typing import overload @overload def foo(value1: str, value2: bool = False) -> str: # this default value is wrong/useless ... @overload def foo(value1: int, value2: bool = False) -> int: # this default value is wrong/useless ... def foo(value1: str | int, value2: bool = True) -> str | int: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11401.py
Python
my_module/__init__.py tests/__init__.py mypy.ini def untyped(): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11404.py
Python
from typing import Optional def test_something(x: Optional[str] = None, y: Optional[str] = None) -> str: if not (x or y): return "early" other: str = x or y # <<< mypy complains that other should be Optional[str] return other #!/usr/bin/env python3 from typing import Optional def test_somet...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11423.py
Python
from typing import Callable def foo(fn: Callable[[int, str], None] | Callable[[int], None]) -> None: ... foo(lambda value: reveal_type(value)) #revealed type is Any
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11425.py
Python
foo: list[str] = [] print(1 in foo) # no error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11426.py
Python
from __future__ import annotations from typing import Literal Foo = Literal[1, 2] Bar = Foo | Literal[3] # error: Unsupported left operand type for | ("object")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11427.py
Python
from typing import Optional from collections.abc import MutableSequence class Item: def __init__(self, comment: Optional[str] = None): self._comment = comment class Array(Item, MutableSequence, list): def __init__(self, values: list, comment: Optional[str] = None): Item.__init__(self, commen...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11428.py
Python
from typing import Generic, TypeGuard, TypeVar, Union L = TypeVar("L") R = TypeVar("R") class Left(Generic[L]): value: L def __init__(self, value: L): self.value = value class Right(Generic[R]): value: R def __init__(self, value: R): self.value = value LeftOrRight = Union[Left[L...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11430.py
Python
def main() -> None: gonna_select = None while True: if gonna_select is not None: print(1 + "lol") gonna_select = "lol"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11436.py
Python
def foo() -> list[int] | list[None]: ... bar = foo() if bar[0] is not None: reveal_type(bar) # Revealed type is "Union[builtins.list[builtins.int], builtins.list[None]]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11437.py
Python
from typing import NoReturn def foo() -> NoReturn: raise Exception def bar() -> NoReturn: foo() foo() print("hi") # no warning
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11439.py
Python
import warnings from typing import NoReturn def foo() -> NoReturn: warnings.warn("this is deprecated", DeprecationWarning) raise NotImplementedError foo() # I would expect a warning here class A: def foo(self) -> None: print() class B(A): def foo(self) -> NoReturn: warnings.warn("th...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11440.py
Python
for it in 1, "1": reveal_type(it) # object
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11449.py
Python
from typing import Any from xxx.commands import XxxBaseCommand class Command(XxxBaseCommand): def handle( # type: ignore[override] self, a: int, b: str, c: str, *args: Any, **options: Any, ) -> None: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11455.py
Python
from typing import Callable, TypeVar A = TypeVar("A") B = TypeVar("B") def func(a: A, b: B, fn: Callable[[A], A]) -> A | B: ... inferred = func( 1, None, lambda value: reveal_type(value), # Revealed type is "builtins.int" ) reveal_type(inferred) # "Union[builtins.int, None]" explicit: int | None...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11461.py
Python
class Planet(Enum): MERCURY = (3.303e+23, 2.4397e6) VENUS = (4.869e+24, 6.0518e6) def __init__(self, mass, radius): self.mass = mass self.radius = radius @property def surface_gravity(self) -> float: G = 6.67300E-11 return G * self.mass / (self.radius * self.radius)...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11463.py
Python
from dataclasses import dataclass from typing import Hashable @dataclass class SusDataclass: b = "AMONGUS" h: Hashable = SusDataclass() # SUS ALERT! d = { SusDataclass(): 1 # SUS ALERT! fails at runtime }
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11464.py
Python
from dataclasses import dataclass @dataclass class Foo: value: int foo = Foo(1) # no error class Bar: value: int Baz = dataclass(Bar) baz = Baz(1) # Too many arguments for "Bar" [call-arg]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11465.py
Python
from typing import Hashable class SomeDClass: __hash__: None = None # type: ignore d = { [1]: 1, # SUS ALERT! fails at runtime SomeDClass(): 2, # SUS ALERT! fails at runtime }
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11467.py
Python
type # no error t1 = type # error: Expression type contains "Any" (has type "Type[type]") t2: type[type] = type # no error t3: Type[type] = type # no error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11469.py
Python
from typing import Hashable o1: type[object] = object o2: type[int] = int t1: type[type] = type o3 = object reveal_type(o1) # note: Revealed type is "Type[builtins.object]" reveal_type(o2) # note: Revealed type is "Type[builtins.int]" reveal_type(t1) # note: Revealed type is "Type[builtins.type]" reveal_type(o3) #...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11470.py
Python
from typing import Hashable, Any t1: type[Any] = type h1: Hashable = t1 # error: Incompatible types in assignment (expression has type "Type[Any]", variable has type "Hashable")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11484.py
Python
from pydantic import BaseModel BaseModelT = TypeVar('BaseModelT', bound=BaseModel) class UserActions(Generic[BaseModelT]): async def create( self, data: 'UserCreateInput', ) -> BaseModelT: ... ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11486.py
Python
from typing import TypeVar, Callable T = TypeVar("T") class A: def __init__(self, a: int) -> None: ... def foo(t: type[T]) -> T: return t() foo(A) # SUS ALERT!
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11488.py
Python
from abc import ABC, abstractmethod from typing import overload class Foo(ABC): @overload # error: An overloaded function outside a stub file must have an implementation @abstractmethod def foo(self, value: int) -> int: ... @overload @abstractmethod def foo(self, value: str) -> str: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11495.py
Python
from dataclasses import dataclass @dataclass(unsafe_hash=False, eq=True, frozen=False) class SecondCase2: x: int __hash__: None # E: Incompatible types in assignment (expression has type "None", base class "object" defined the type as "Callable[[object], int]") print(SecondCase2(1).__hash__) # N: Revealed ty...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11500.py
Python
def hook_func(ctx: AttributeContext) -> Type: ... class MyPlugin(Plugin): def get_attribute_hook(self, fullname: str) -> ...: return hook_func def hook_gen(name: str): def hook_func(ctx: AttributeContext) -> Type: ... return hook_func class MyPlugin(Plugin): def get_attribute_hook...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11503.py
Python
import mod import package mod.func(package.things.Thing()) def func(it): ... from package.things import Thing def func(it: Thing) -> None: ... class Thing: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11508.py
Python
from typing import Generic, Mapping, NoReturn, Sequence, TypeVar T = TypeVar("T", contravariant=True) class Foo(Generic[T]): ... foo = Foo[int]() bar = Foo[str]() a1: Sequence[Foo[NoReturn]] = [foo] # no error a2: Sequence[Foo[NoReturn]] = [bar] # no error # error (this one seemed to be fixed around commit...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11510.py
Python
def func1(cond: bool): if cond: def a(a: int, /) -> None: return None b: Callable[[int], None] = lambda a: None else: a: Callable[[int], None] = lambda a: None # Mypy error: Name "a" already defined def b(a: int, /) -> None: return None
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11513.py
Python
from b import B from a import b main = B() from b import b as b from main import main reveal_type(main) b = 1 class B: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11514.py
Python
def bad_reader(path: str) -> bytes: if path == "bad": raise PermissionError with open(path, "rb") as f: return f.read() def load_data(path: str) -> bytes: try: return bad_reader(path) except OSError: print("OSError caught") except PermissionError: # This br...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11516.py
Python
def func1(f: float): reveal_type(f) # float | int | complex def func2(b: bytes): reveal_type(b) # bytes | bytearray | memoryview def func3(u: unicode): # python 2 moment reveal_type(u) # unicode | str def func(f: float): f.is_integer() # error: int has no member "is_integer" def func(f: float):...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11519.py
Python
reveal_type("shaking") # Literal["shaking"]? reveal_type(int("1")) # builtins.int* from typing import TypeVar T = TypeVar("T") def foo(t: T) -> T: reveal_type(t) # T`-1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11520.py
Python
from typing import cast class Test: a: int t = Test() cast(t.a, int) # error: Name "t.a" is not defined
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11529.py
Python
from collections.abc import MutableMapping MutableMapping[int, int]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11536.py
Python
from typing import TypeVar T = TypeVar("T", int, str) def foo() -> T: return 1 # error: Incompatible return value type (got "int", expected "str") [return-value] def bar() -> T: return "" # error: Incompatible return value type (got "str", expected "int") [return-value]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11537.py
Python
from typing import Generic, TypeVar T = TypeVar("T") class A(Generic[T]): class_attr: T @classmethod def set_attr(cls, arg: T) -> None: cls.class_attr = arg # no error? B = A[str] B.set_attr("1") B.class_attr = "1" # error: Access to generic instance variables via class is ambiguous C = A[i...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11538.py
Python
from typing import Generic, TypeVar T = TypeVar("T") class A(Generic[T]): shared_attr: list[T] = [] a1 = A[str]() a1.shared_attr.append("AMONGUS") a2 = A[int]() a2.shared_attr.append(1) value = a2.class_attr[0] reveal_type(value) # revealed type: int, actual value: AMONGUS
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11539.py
Python
type(None).__bool__
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11549.py
Python
from __future__ import annotations from typing import Generic, TypeVar, ClassVar, Any T = TypeVar("T") class A(Generic[T]): @classmethod def bar(cls: type[A[int]]) -> None: ... A.bar() # error: Invalid self argument "Type[A[Any]]" to attribute function "bar" with type "Callable[[Type[A[int]]], Non...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11550.py
Python
reveal_type(type) none = type(None) reveal_type(none)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11553.py
Python
class MyDict(TypedDict, total=False): a: int b: str ... MyDictKeys = Union[Literal['a'], Literal['b']] def is_mydict_key(key: str) -> TypeGuard[WidgetOptionKeys]: return key in MyDictKeys.__annotations__
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11554.py
Python
import bar class Foo: def __init__(self) -> None: self.view_selector = object() from foo import Foo class ServerView: def __init__(self) -> None: print(ChannelView().userlist) self.view_id = str(Foo().view_selector) class ChannelView: def __init__(self) -> None: print(Ser...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11565.py
Python
from typing import Any from typing import AnyStr from typing import Generic class Message(Generic[AnyStr]): header: AnyStr content: AnyStr def __init__(self, header: AnyStr, content: AnyStr) -> None: self.header = header self.content = content # This feels wrong to me, and I'd rather see...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11568.py
Python
# main.py from drf_spectacular.utils import Direction def go(direction: Direction) -> int: if direction == "request": return 1 elif direction == "response": return 2 from drf_spectacular.drainage import ( Final, Literal, error, get_view_method_names, isolate_view_method, set_override, war...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11582.py
Python
from typing import TypeAlias AMONGUS: TypeAlias = "int" IMPOSTER: TypeAlias = "str" a: AMONGUS | IMPOSTER = 0 # SUS ALERT b: AMONGUS | None = None # SUS ALERT
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11583.py
Python
from typing import Any, Optional, TypeVar _T = TypeVar('_T') def f(b: bool = True, **kwargs: Any) -> None: pass def g(x: _T) -> _T: f(**{'x': x}) return x
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11592.py
Python
from typing import type_check_only
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11595.py
Python
from __future__ import annotations import numpy as np class my_float: def __radd__(self, other: np.float32) -> my_float: return my_float() a = np.float32() b = np.float32() reveal_type(a + b) # Revealed type is "numpy.floating[numpy.typing._32Bit]" class _FloatOp(Protocol[_NBit1]): @overload ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11604.py
Python
from typing import Mapping def f(x: Mapping[str, object]) -> int: d = { "foo": 3.14, **x, } return len(d)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11605.py
Python
import typing class A: pass class B: pass T = typing.TypeVar("T", bound=A) V = typing.TypeVar("V", bound=B) _WhateverT = typing.TypeVar("_WhateverT", bound="Whatever[typing.Any]") _WhateverPartTwoT = typing.TypeVar("_WhateverPartTwoT", bound="WhateverPartTwo[typing.Any]") class Whatever(typing.Generic[T]): d...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11610.py
Python
from typing import TypeVar, Callable, Iterable, Optional, List, Any T = TypeVar("T") def g(f: Callable[[T, T], T], seq: Iterable[Optional[T]]) -> Optional[T]: ... a: List[Any] # Incompatible types in assignment (expression has type "Optional[SupportsLessThanT]", variable has type "Optional[int]") b: Optional[int] = ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11612.py
Python
a = None for b in [1, 2]: if a is None: a = b continue print("hi") # false unreachable error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11613.py
Python
@overload def __sub__(self, other: Union[timedelta, relativedelta]) -> "Arrow": pass # pragma: no cover @overload def __sub__(self, other: Union[dt_datetime, "Arrow"]) -> timedelta: pass # pragma: no cover def __sub__(self, other: Any) -> Union[timedelta, "Arrow"]: if isinstance(other, (timedelta, rela...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11615.py
Python
from collections.abc import Collection, Mapping def f(x: int | Collection[int] | Mapping[str, int]) -> int: r"""Recursively sum up all the values of possibly nested data.""" if isinstance(x, int): return x if isinstance(x, Mapping): return sum(f(y) for y in x.values()) reveal_type(x) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11616.py
Python
from typing import Literal def page(page: Literal["p1", "p2"]): ... def foo(num: Literal["1", "2"]): page(f"p{num}") page("p" + num) page("p" + "1")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11618.py
Python
def foo(x: Optional[dict] = None): if x is None: x = {} from typing import Optional, TypeVar T = TypeVar("T") def assign_if_none(obj: Optional[T], assignment: T) -> T: return assignment if obj is None else obj def foo(x: Optional[dict] = None): x = assign_to_none(x, {}) from typing import Map...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11619.py
Python
class Foo: @classmethod @property def bar(cls) -> str: return cls.__name__ def foo_bar(msg: str) -> None: print(msg) foo_bar(Foo.bar)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11625.py
Python
from typing import Iterable, Dict, Any def f(x: Iterable[Dict[str, str]]) -> None: pass # Lists all work as expected f([]) f([{}]) f([{"k": "v"}]) # Empty tuple works f(()) # Tuple of empty dict doesn't work f(({},)) # Tuple with non-empty dict works f(({"k": "v"},)) f(({},))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11640.py
Python
import numpy as onp import numpy.typing as onpt imin: onpt.NDArray[onp.int64] = onp.array(0) imax: onpt.NDArray[onp.int64] = onp.array(2) M = onp.array([1.0, 2.0, 3.0, 4.0]) print(M[imin:imax]) import numpy as onp import numpy.typing as onpt imin: onpt.NDArray[onp.int64] = onp.array(0) imax: onpt.NDArray[onp.int64] = ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11648.py
Python
from typing import Union class MyUnion(type): ... class Meta(type): def __or__(self, other) -> MyUnion: ... # type: ignore class Foo(metaclass=Meta): ... reveal_type(Foo | Foo) # line 12 isinstance(object(), Foo | Foo) Bar = Foo | Foo reveal_type(Bar) # line 14 isinstance(object(), Bar) # line 15 clas...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11655.py
Python
from typing import TypeVar, Generic T1, T2 = TypeVar('T1'), TypeVar('T2') class Container(Generic[T1]): class Item(Generic[T2]): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11659.py
Python
from typing import Type, List class NonLiskovChild(Exception): """Does not match Exception.__init__() signature""" def __init__(self, _some_other_arg: object) -> None: super().__init__() types1 = [TypeError, ValueError] reveal_type(types1) # Revealed type is 'builtins.list[def (*args: builtins.objec...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11661.py
Python
from __future__ import annotations import typing as t @t.overload def func2(a: int, b: str, x: t.Callable[[int], int], y: t.Callable[[str], int]) -> tuple[int, int]: ... @t.overload def func2(a: int, b: str, x: t.Callable[[t.Union[int, str]], int]) -> tuple[int, int]:...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11664.py
Python
from typing import Any, Generic, TypeVar T = TypeVar("T") class Foo(Generic[T]): def __init__(self, value: T): self.value = value def identity(value: T) -> Foo[T]: if isinstance(value, str): return Foo(value) return Foo(value)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11671.py
Python
class FooMetaclass(type): pass class Foo(metaclass=FooMetaclass): pass fm: FooMetaclass reveal_type(fm) # note: Revealed type is "__main__.FooMetaclass" if issubclass(fm, Foo): reveal_type(fm) # note: Revealed type is "__main__.FooMetaclass"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11672.py
Python
from typing import TypeVar, Generic T = TypeVar("T") class FooMetaclass(type, Generic[T]): pass class Foo(metaclass=FooMetaclass[T]): # error: Dynamic metaclass not supported for "Foo" pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/11000-11999/11673.py
Python
Foo = int | str foo: object isinstance(foo, Foo) # error isinstance(foo, int | str) # no error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli