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/10000-10999/10178.py
Python
from dataclasses import dataclass from typing import Generic, TypeVar, Union, NoReturn def assert_never(a: NoReturn) -> NoReturn: raise AssertionError("Unhandled type: {}".format(type(a).__name__)) @dataclass class Nothing: pass T = TypeVar("T") @dataclass class Just(Generic[T]): value: T Maybe = ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10185.py
Python
from typing import Dict, Optional foo_dict: Dict[str, Optional[str]] = {'bar': 'baz'} if foo_dict['bar'] is not None: foo_dict['bar'] = None foo_dict['bar'].upper() from dataclasses import dataclass from typing import Optional @dataclass class Foo: bar: Optional[str] foo = Foo(bar='baz') if foo.bar is...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10187.py
Python
import re import attr @attr.s(auto_attribs=True) class GHRepo: owner: str name: str def parse_ghrepo(s: str) -> GHRepo: if (m := re.fullmatch(r'([^/]+)/([^/]+)', s)) is not None: return GHRepo(owner=m[1], name=m[2]) else: raise ValueError(s) @attr.s class Foo: repo: GHRepo = att...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10188.py
Python
from typing import Generator def f() -> Generator[int, None, str]: yield 1 return "lol" def g() -> Generator[int, None, None]: x = [(yield from f()) for lel in range(5)] print(x) # <generator object g.<locals>.<listcomp> at 0x7fba92696a20> reveal_type(x) # List[str] g()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10197.py
Python
class A: def foo(self, s: str) -> str: ... class B(A): def foo(self, n: float) -> float: ... # type: ignore class C(B): def foo(self, n: float) -> float: ... class Pattern: def handleMatch(self, m: Match) -> Optional[Union[str, Element]]: ... class InlineProcessor(Pattern): def handleMatch(self,...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10198.py
Python
from .mysub import MyName from .mysub import MyName as MyName from .mysub import MyName __all__ = ['MyName']
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10200.py
Python
from .mydc import MyDataclass class MyClass: pass import dataclasses from typing import Optional from typing import TYPE_CHECKING if TYPE_CHECKING: from .myclass import MyClass @dataclasses.dataclass class MyDataclassBase: my_field: Optional['MyClass'] import dataclasses from .mydc_base import MyDa...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10207.py
Python
class A: def __init__(self, return_tuple=False): self.return_tuple = return_tuple def __call__(self): if self.return_tuple: return (1, 2) return 1 T = TypeVar("T", bool) T = TypeVar("T", Literal[True], Literal[False])
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10218.py
Python
x = lambda: quit() print(1) # ok if __name__ == "__main__": print(2) # Mypy: Statement is unreachable
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10224.py
Python
from typing import Any, Union class A: ... class B: ... class C: ... def _binary_operation(left: C, right: Union[A, B]) -> Any: ... ALL = Union[A, B, C] def commutative_binary_operation(left: ALL, right: ALL) -> Any: # Handling of a corner case. if isinstance(left, C) and isinstance(right, C): ... ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10225.py
Python
from typing import Union, Tuple def def1(var: bool) -> Union[Tuple[str, str], Tuple[None, None]]: a, b = "", "" if var: return a, b return None, None from typing import Union, Tuple def def1(var: bool) -> Union[Tuple[str, str], Tuple[None, None]]: if var: return "", "" return None,...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10241.py
Python
from typing import Optional, TypeVar T1 = TypeVar("T1") def func1(suffix: Optional[T1] = ...) -> T1: ... T2 = TypeVar("T2", bound=str) def func2(suffix: Optional[T2] = ...) -> T2: ... T3 = TypeVar("T3", str, bytes) def func3(suffix: Optional[T3] = ...) -> T3: ... T4 = TypeVar("T4", bytes, str) def func4...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10244.py
Python
from dataclasses import dataclass from typing import Generic, TypeVar, Callable T = TypeVar('T') R = TypeVar('R') X = TypeVar('X') @dataclass class Box(Generic[T]): inner: T @dataclass class Cont(Generic[R]): run: Box[Callable[[X], R]] def f(c: Cont[R]) -> R: return c.run.inner(3) def const_two(x: T) -...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10246.py
Python
class X: y: int = descriptor() class X: y: descriptor[int] = descriptor()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10272.py
Python
from ctypes import Structure from typing import Iterable class S(Structure): pass s = S() if isinstance(s, Iterable): for _ in s: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10274.py
Python
try: from emoji import emojize reveal_type(emojize) except ModuleNotFoundError: def emojize(string: str, use_aliases=False, delimiters=(':', ':'), variant=None, language='en'): return string reveal_type(emojize)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10275.py
Python
class A(MutableMapping[str, Any]): pass def something() -> A: pass something() == {}
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10281.py
Python
from typing import ( Callable, TypeVar, Union, Tuple, ) T = TypeVar("T") def test(pred: Callable[[T], bool]) -> Tuple[Union[T, int]]: return (1,) def main(pred: Callable[[T], bool]) -> None: (val,) = test(pred) # the error appears here def f(x: int) -> bool: return x > 1 main(f)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10287.py
Python
# mypy: warn_unreachable from typing import Generic, TypeVar, Union T = TypeVar("T") class A(Generic[T]): pass class B(Generic[T]): pass AorB = Union[A[T], B[T]] x: AorB if isinstance(x, A): print("A") elif isinstance(x, B): print("B") else: # correctly identified as unreachable reveal_type(x) pr...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10289.py
Python
from typing import * class Foo(Protocol): @property def foo(self) -> int: ... class Bar: foo : ClassVar[int] = 42 x : Foo = Bar()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10299.py
Python
from functools import partial from typing import Any, Callable, Generic, Tuple, TypeVar ReturnValue = TypeVar('ReturnValue') class custom_vjp(Generic[ReturnValue]): def __init__(self, fun: Callable[..., ReturnValue], nondiff_argnums: Tuple[int, ...] = ()): self.fun = fun def _...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10302.py
Python
from typing import TypeVar class A: pass class B: pass OperableT = TypeVar( "OperableT", A, B, ) class Operator: def process(self, obj: OperableT) -> OperableT: if isinstance(obj, A): return A() elif isinstance(obj, B): return B()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10304.py
Python
# mypy: ignore-errors # type: ignore # mypy: disable-error-code="valid_type"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10312.py
Python
from __future__ import annotations from typing import Any, Generic, TypeVar, overload, List from typing_extensions import Literal _T = TypeVar("_T") class ListField(Generic[_T]): @overload def __init__( self: ListField[int], *, kind: Literal["integer"], ) -> None: ... ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10314.py
Python
class Test: pass __all__ = [] class Test: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10319.py
Python
from typing import Any, Iterable, Mapping def foo(foo: Iterable[Mapping[str, Any]]) -> None: pass foo(({},))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10336.py
Python
from __future__ import annotations from typing import overload class Money: @overload def __init__(self, amount: object = ..., *, currency: str) -> None: ... @overload def __init__(self, amount: object, currency: str) -> None: ... def __init__( self, amount: objec...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10337.py
Python
class Name: name: str = "" class Inner: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10339.py
Python
def move(command: Iterable[Literal["f", "b", "l", "r"]]) -> None: for c in command: print(c) move("ffbblr") move(["f", "f", "b", "b", "l", "r"])
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10342.py
Python
class A: def __init__(self): raise RuntimeError from typing import NoReturn class A: def __init__(self) -> NoReturn: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10348.py
Python
# error: "datetime" gets multiple values for keyword argument "tzinfo" dt.datetime(*split_int_string(date, 4, 6, 8), *split_int_string(time, 2, 4)) # or # error: "datetime" gets multiple values for keyword argument "tzinfo" dt.datetime(*split_int_string(date, 4, 6, 8), *split_int_string(time, 2, 4), tzinfo=None) def...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10357.py
Python
import http.server import threading from typing import Optional, Type class ThreadedHttpServer: def __init__( self, host: str, port: int, custom_server: Type["CustomServer"], custom_attribute: str, ) -> None: self.host = host self.port = port sel...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10360.py
Python
from google.cloud import bigquery from google.cloud import logging from google.cloud import bigquery # from google.cloud import logging
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10371.py
Python
from typing import TypedDict, List class Dct(TypedDict): x: int def foo() -> List[Dct]: return [item for item in [{"x": 3}]] from typing import TypedDict, List class Dct(TypedDict): x: int def foo() -> List[Dct]: return [{"x": 3}]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10375.py
Python
from typing import List class A: a: List[int] class B(A): a = [] # error: Need type annotation for 'a' (hint: "a: List[<type>] = ...") from typing import List class A: def __init__(self) -> None: self.a: List[int] class B(A): def __init__(self) -> None: super().__init__() s...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10380.py
Python
from typing import Union def semver_prerelease_compare(lhs: str, rhs: str) -> bool: a: Union[str, int] b: Union[str, int] for a, b in zip(lhs.split("."), rhs.split(".")): try: a = int(a) except ValueError: pass try: b = int(b) except Value...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10394.py
Python
import typing NoneType = type(None) class NullableString: @typing.overload def __new__(cls: type, arg: None) -> 'NoneType': pass @typing.overload def __new__(cls: type, arg: str) -> 'NullableString': pass def __new__(cls: type, arg: typing.Optional[str]): if arg is None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10399.py
Python
from typing import Any, Protocol, Union class HasName(Protocol): def __name__(self) -> str: ... class Animal: def __name__(self) -> str: ... class Dog(Animal): def __name__(self) -> str: ... def run(self) -> None: print("Run Spot Run!") def bark(self) -> None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10403.py
Python
from typing import Protocol class A(Protocol): __name__: str def __call__(self) -> None: ... def f() -> None: ... reveal_type(f.__name__) # note: Revealed type is 'builtins.str' a: A = f # error: Incompatible types in assignment (expression has type "Callable[[], None]", variable has type "A") [assignment...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10425.py
Python
from typing import Any, Union def function(arg: Union[Any, Any]) -> None: reveal_type(1 + arg)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10426.py
Python
from typing import Optional animals = ["cow"] def find1(name: str) -> Optional[str]: return next( filter( lambda animal: animal.upper() == name, animals, ), None, ) def find1(name: str): return next( filter( lambda animal: animal.upper(...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10427.py
Python
from typing import TypeVar, Generic class T: ... class M(T): ... class B(M): ... InMT = TypeVar('InMT', bound=M) ContraMT = TypeVar('ContraMT', bound=M, contravariant=True) CoMT = TypeVar('CoMT', bound=M, covariant=True) class In(Generic[InMT]): x: InMT class Contra(Generic[ContraMT]): x: ContraMT class Co(G...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10434.py
Python
def f(g: callable) -> None: g() f(f) f('a')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10439.py
Python
def func_1(address: Address) -> Optional[float] : ... def func_2(addresses: Tuple[Addresses, ...]) -> Optional[Tuple[float, ...]]: ordered_tuple = tuple( func_1(address) for address in addresses) return ordered_tuple if not None in ordered_tuple else None def func_1(address: Address) -> Op...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10442.py
Python
from __future__ import annotations from typing import Any, Iterator l_int: list[int] = [1, 2] l_str: list[str] l_str = ["a", "b"] l_union: list[str] | list[bytes] l_union = ["a", "b"] def iter_yield() -> Iterator[list[Any]]: yield l_int yield l_str # this passes def iter_yield_from() -> Iterator[list[A...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10465.py
Python
items = (foo.bar for foo in all_the_foos) for x in y: if x in items: do_sparkle_hands_stuff() y in (x.foo for x in foos) any(y == x.foo for x in foos) for y in sorted_y: if y in sorted_x: # sorted_x is an iterator ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10468.py
Python
from collections import deque from typing import TypedDict, Dict, Deque class MyTypedDict(TypedDict): pass Step = Dict[int, MyTypedDict] a: Deque[Step] = deque([{}]) # OK b: Deque[Step] = deque(({},)) # MyPy error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10470.py
Python
from collections import namedtuple from typing import Any, Callable, cast, Dict, List, NamedTuple, overload, TypeVar, Union F = TypeVar("F", bound=Callable[..., Any]) Arg: NamedTuple = namedtuple("Arg", ["arg"]) class Test: @overload def __call__(self, fn: F) -> F: ... @overload def __call__...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10479.py
Python
from typing import Generic, Iterable, TypeVar T = TypeVar('T') S = TypeVar('S') class Outer(Generic[T]): class Bad(Iterable[T]): # Error ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10480.py
Python
def f() -> int: error_here() return 1 f(wat=1)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10482.py
Python
from typing import Protocol class Factory(Protocol): def __call__(self) -> Result: ... class Result(Protocol): a: int class BadImplementation: ... def bad_implementation() -> BadImplementation: ... something: Factory = BadImplementation # no error something_else: Factory = bad_implemen...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10484.py
Python
from typing import Protocol class P(Protocol): def foo(self, n: int = 666) -> None: ... class F: def foo(self, n: int = 666) -> None: ... class S: def foo(self, n: int = 999) -> None: ... def bar(x: P) -> None: ... bar(F()) bar(S())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10487.py
Python
from __future__ import annotations from typing import Any def passes() -> tuple[str]: a: Any return (a,) def fails_1() -> tuple[str]: a: int return (a,) # error: Incompatible return value type (got "Tuple[int]", expected "Tuple[str]") def fails_2() -> str: a: Any return a # error: Ret...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10499.py
Python
from __future__ import annotations def f(a: int | str = None): pass from typing import Union def f(a: Union[int, str] = None): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10500.py
Python
def my_sorted(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan], reverse: bool = ...) -> List[_T]: ... from __future__ import annotations from typing import TypeVar T = TypeVar("T") def unwrap(val: T | None) -> T: assert val is not None return val x: list[str | None] sorted(x, key=lambda...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10504.py
Python
import csv from typing import Callable, Iterable, Iterator, Text, TypeVar T = TypeVar('T') def foo(x: str, reader: Callable[[Iterable[Text]], Iterator[T]]) -> Iterator[T]: return reader(x) # Is fine, resolves to Iterator[List[str]] x = foo('bar.txt', csv.reader) # Complains that _reader is not compatible with...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10506.py
Python
from typing import ClassVar, List class Seat(object): ... class LeatherSeat(Seat): ... class PlasticSeat(Seat): ... class SomeBucket(Seat): ... ############## # Failing Case 1 class TransportMedium(object): seats: ClassVar[List[Seat]] = [] class Car(TransportMedium): ... class Elec...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10514.py
Python
from typing import Literal, Union Foo = Union[Literal[-1], Literal[42]] def correct(f: Foo) -> None: if f == 42: reveal_type(f) # Revealed type is 'Literal[42]' else: reveal_type(f) # Revealed type is 'Literal[-1]' def also_correct(f: Foo) -> None: if f == -2: reveal_type(f) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10516.py
Python
import asyncio from typing import Optional def g() -> int: return 1 async def f(x: Optional[int] = None) -> int: loop = asyncio.get_running_loop() if x is not None: return x x = await loop.run_in_executor(None, g) return x ... fut = loop.run_in_executor(None, g) x = await fut return x...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10518.py
Python
import typing as t T = t.TypeVar('T') R = t.TypeVar('R') Collector = t.Callable[[t.Iterable[T]], R] def collect(it: t.Iterable[T], collector: Collector[T, R]) -> R: return collector(it) collect(['str'], sorted) # Argument 2 to "collect" has incompatible type overloaded function; expected "Callable[[Iterable[str]]...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10520.py
Python
class Possibility(Generic[T]): def __init__(self, produce: Callable[[], T]): self._produce = produce def produce(self) -> T: return self._produce() def reject() -> NoReturn: raise RuntimeError def nothing() -> Possibility[NoReturn]: return Possibility(lambda: reject()) # Error here
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10522.py
Python
from typing import Protocol, runtime_checkable @runtime_checkable class Foo(Protocol): class Bar: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10530.py
Python
from typing import Any, Dict foo: Dict[str, str] bar: Dict[Any, int] = {} foo = bar # Incompatible types in assignment (expected, correct) foo = dict(bar) # no error (unexpected, IMO incorrect)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10534.py
Python
import asyncio from typing import AsyncGenerator async def get_value(v: int) -> int: await asyncio.sleep(1) return v + 1 def get_generator() -> AsyncGenerator[int, None]: return (await get_value(v) for v in [1, 2, 3]) async def test() -> None: print(type(get_generator())) async for x in get_ge...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10545.py
Python
# a.pyi def foo() -> str: ... # b.pyi from a import * def foo() -> int: ... # type: ignore
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10547.py
Python
from typing import Any b: Any def foo(a: Any): if isinstance(a, (str, b)): return True return False # Statement is unreachable
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10552.py
Python
class Tst: def __init__(self) -> None: ... def create_field(self) -> None: self.abc = 1 # Please, generate error here def print_field(self) -> None: print(self.abc) # And, optionally here... def main() -> None: tst = Tst() tst.print_field() if __name__ == '__main__': ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10553.py
Python
from typing import Final, Optional, TypedDict KEY_NAME: Final = "bar" class Foo(TypedDict): bar: Optional[str] foo = Foo(bar="hello") if foo["bar"] is not None: # ok string1: str = foo["bar"] # (expression has type "Optional[str]", variable has type "str") string2: str = foo[KEY_NAME] if foo...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10559.py
Python
class MessageIdStore: def __init__(self): self.__msgid_to_symbol: Dict[str, str] = {} self.__symbol_to_msgid: Dict[str, str] = {} def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10563.py
Python
# a.py x: int # and many more definitions # b.py from a import * x: str # Name "x" already defined (possibly by an import) reveal_type(x) # Revealed type is "builtins.int"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10570.py
Python
class Foo: print(__doc__) print(__name__) print(__qualname__) # error: Name '__qualname__' is not defined print(__module__) # error: Name '__module__' is not defined
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10573.py
Python
from enum import IntEnum from typing import Final, Type class Colour(IntEnum): value: int r: Final[int] g: Final[int] b: Final[int] RED = 0, b"\xFF\x00\x00" GREEN = 1, b"\x00\xFF\x00" BLUE = 2, b"\x00\x00\xFF" def __new__(cls: Type["Colour"], value: int, _hue: bytes) -> "Colour": ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10574.py
Python
def foo(a: str) -> None: ... # pseudo code def bar(*args: foo.args, **kwargs: foo.kwargs) -> foo.return_type: return foo(*args, **kwargs) def bar(*args: ParamSpec[foo].args, **kwargs: ParamSpec[foo].kwargs) -> None: return foo(*args, **kwargs)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10575.py
Python
try: from math import comb except ImportError: def comb(n: int, k: int) -> int: # All conditional function variants must have identical signatures return int(factorial(n) / factorial(k) / factorial(n - k)) import sys if sys.version_info >= (3, 8): from math import comb else: def comb(n: int, k...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10577.py
Python
# $ cat mypy-bug.py from typing import Protocol, Union from typing_extensions import runtime_checkable from operator import add as op_add class Foo: pass # FooAbleOperandT = Union[int, float, Foo, "FooAbleT"] # <- this will work @runtime_checkable class FooAbleT(Protocol): FooAbleOperandT = Union[int, float, Fo...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10580.py
Python
# foo.pyx def _foo(): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10585.py
Python
class Foo(TypedDict): a: int b: int class Bar(Foo): c: int foo = Foo(a=1, b=2)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10588.py
Python
list_of_ints: list[int] = [1,2,3] reveal_type(["a", "b"] or [1,2,3]) # Produces error. Revealed type is 'builtins.list[builtins.str*]' reveal_type(["a", "b"] or 123) # Works. Revealed type is 'Union[builtins.list[builtins.str*], Literal[123]?]' reveal_type(123 or [1,2,3]) # Works. Revealed type is 'Union[Literal[12...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10593.py
Python
from typing import Any, Dict, List, TypedDict, TypeVar, Type, TYPE_CHECKING class User(TypedDict): id: int name: str users: List[Dict[str, Any]] = [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}] T = TypeVar("T") def try_cast(cls: Type[T], data: Any) -> T: return cls(**data) # type: ignore for u...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10612.py
Python
def a(x: str) -> str: return x b: int = a('1') # Obviously mypy should raise something here
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10617.py
Python
class object: __doc__: Optional[str] __dict__: Dict[str, Any] __slots__: Union[str, Iterable[str]] __module__: str __annotations__: Dict[str, Any] @property def __class__(self: _T) -> Type[_T]: ... # Ignore errors about type mismatch between property getter and setter @__class__.sett...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10634.py
Python
foo = None def bar() -> str: global foo if foo is not None: print("Hello") else: foo = "bar" return "lol"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10636.py
Python
var: Optional[List[Optional[int]]] = [1,2] # mypy has no issue with this from dataclasses import dataclass, field from typing import Dict, Optional @dataclass class SubscriptedDict: opt_dict_opt: Optional[Dict[str, Optional[int]]] = field(default_factory=lambda: {"foo": 123})
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10640.py
Python
from dataclasses import dataclass, field from typing import List @dataclass class FilterExpression: match_type: str field: str value: List[str] = field(default_factory=list)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10659.py
Python
from typing import Literal, TypedDict, Union class TaggedTypeA(TypedDict): tag: Literal["A"] is_a: bool class TaggedTypeB(TypedDict): tag: Literal["B"] TaggedUnion = Union[TaggedTypeA, TaggedTypeB] instance_a: TaggedUnion = {"tag": "A", "is_a": True} if instance_a["tag"] == "A": print(f"Am I typ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10672.py
Python
# test.py from typing import (NamedTuple, Generic, TypeVar) S = TypeVar('S', bound='_S') class _S: pass class A(NamedTuple, Generic[S]): s: S # test.py from typing import (NamedTuple, Generic, TypeVar) class _S: pass S = TypeVar('S', bound='_S') class A(NamedTuple, Generic[S]): s: S
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10673.py
Python
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: Point = tuple[int, int] # mypy error: "tuple" is not subscriptable def foo(p: Point) -> None: print(p)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10680.py
Python
from typing import Type def untyped_function(): return int def foo() -> Type[int]: x = untyped_function() assert issubclass(x, int) return x
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10682.py
Python
from asyncio import gather async def returns_dict() -> dict: return {} async def returns_int() -> int: return 1 async def test(): tasks = (returns_dict(), returns_int()) reveal_type(await gather(*tasks)) # note: Revealed type is "Any" from asyncio import gather async def returns_dict() -> dict...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10691.py
Python
from typing import Union, TypeVar, overload class C1:... class C2:... T = TypeVar('T', bound=Union[C1, C2]) @overload def update(elt: C1) -> C1:... @overload def update(elt:C2) -> C2:... def update(elt: Union[C1, C2]) -> Union[C1, C2]: pass def get_copy(elt: T) -> T: new_elt = update(elt) return new_elt
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10695.py
Python
from typing import Any test: Any[int,str] = "Test" print(test)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10696.py
Python
FOO = frozenset("abc") BAR = FOO and next(iter(FOO))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10699.py
Python
from __future__ import annotations import abc from typing import Literal, Mapping, overload class AdapterBase(abc.ABC): @overload def get_map_or_value(self, *, as_dict: Literal[True]) -> Mapping[str, str]: ... @overload def get_map_or_value(self, *, as_dict: Literal[False] = ...) -> str: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10704.py
Python
import functools @functools.cache def factorial(n: int) -> int: return n * factorial(n-1) if n else 1 def identity(n: int) -> int: return n if __name__ == '__main__': print(factorial.__name__, factorial.__annotations__) print(identity.__name__, identity.__annotations__) factorial("") ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10708.py
Python
from enum import IntEnum class MyIntEnum(IntEnum): A = 1 B = 2 m: MyIntEnum if m == 1: pass else: reveal_type(m)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10711.py
Python
from dataclasses import dataclass from typing import Callable @dataclass class Repro: fn: Callable[[int], str] r = Repro(fn=repr) assert "1" == r.fn(1) from dataclasses import dataclass from typing import Callable @dataclass(frozen=True) class Repro: fn: Callable[[int], str] r = Repro(fn=repr) assert "1" =...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10721.py
Python
class Cmd: prompt = '> ' ... class MyCmd(cmd.Cmd): @property def prompt(self): if self.some_condition(): return '$ ' else: return '> ' @prompt.setter def prompt(self, value: str) -> None: raise NotImplementedError ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10722.py
Python
from enum import Enum class WSMessageType(Enum): LEGACY = 1 def __str__(self) -> str: return self.name.lower()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10733.py
Python
import attr @attr.s(auto_attribs=True, slots=True) class UpperString(): """Uppercase string.""" value: str = attr.ib(converter=str.upper)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10736.py
Python
from typing import Final, Optional class Foo: a: Final[Optional[int]] def __init__(self, v: int) -> None: if v == 0: self.a = None else: self.a = v # error: Cannot assign to final attribute "a" [misc]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli