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/12000-12999/12824.py
Python
from typing import NewType Euro = NewType("Euro", float) def to_eur(user_in: int | float | str) -> Euro: reveal_type(user_in) # int | float | str as expected if isinstance(user_in, float): reveal_type(user_in) # float return Euro(user_in) reveal_type(user_in) # str, but expected str | int ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12825.py
Python
from threading import Lock # Use this lock to ensure that only one thread is executing a function # at any time. my_lock = Lock() def with_lock(f): '''A decorator which provides a lock.''' def inner(*args, **kwargs): # Provide the lock as the first argument. return f(my_lock, *args, **kwargs) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12829.py
Python
z1 = list(zip((1, 10), (2, 20), (3, 30))) # correct: list[Tuple[int, int, int]] z2 = list(zip(*[(1, 10), (2, 20), (3, 30)])) # list[tuple[Any, ...]] but I expect list[tuple[int, int, int]]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12831.py
Python
{ "covers": [ [ 1, "/media/manga/Kaguya-Wants-To-Be-Confessed-To/volume_covers/1/1.png", "/media/manga/Kaguya-Wants-To-Be-Confessed-To/volume_covers/1/1.webp", "/media/manga/Kaguya-Wants-To-Be-Confessed-To/volume_covers/1/1_blur.png", ], [ ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12837.py
Python
def nothing() -> None: ... def foo() -> None: x = nothing() # E: "nothing" does not return a value async def async_nothing() -> None: ... async def async_foo() -> None: x = await async_nothing()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12841.py
Python
from enum import Enum, verify, UNIQUE @verify(UNIQUE) class Color(Enum): RED = 1 GREEN = 2 BLUE = 3 CRIMSON = 1 from enum import Enum, nonmember class Foo(Enum): BAR = 1 BAZ = nonmember(2)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12842.py
Python
from typing import Generic, TypeVar T_co = TypeVar("T_co", covariant=True) class FooGeneric(Generic[T_co]): pass def accepts_foo(x: FooGeneric[T_co]) -> None: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12844.py
Python
from typing import Callable, TypeVar from typing_extensions import ParamSpec P = ParamSpec('P') R = TypeVar('R') def wrapper(func: Callable[P, R]) -> Callable[P, R]: return func wrapper(list)([1, 2, 3]) # "Too many arguments"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12845.py
Python
from collections.abc import Mapping from typing import TypeVar T = TypeVar("T") S = TypeVar("S") def swap(x: Mapping[T, S]) -> Mapping[S, T]: if isinstance(x, dict): return x else: raise Exception
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12846.py
Python
from typing import Hashable, Mapping, Any, TypeVar T = TypeVar("T", bound="A") class A: def a( self: T, x: Hashable | Mapping[Any, Any] ) -> T: return self s = A() s.a("asd") # ok s.a({"a": 1}) # fails
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12856.py
Python
from wsgiref.types import WSGIEnvironment, StartResponse, InputStream from typing import Iterable def f(a: str) -> int: return int(a) def wsgi_callable(environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: # No error: content_length1 = f(environ['CONTENT_LENGTH']) # error: Expression has t...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12860.py
Python
import builtins builtins.foo = 42
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12865.py
Python
import dateutil.rrule dateutil.rrule.weekdays
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12866.py
Python
a: str = "foo" print(a) # value needs to be used before redefinition a: int # but it is really still str if a > 1: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12867.py
Python
import asyncio async def crash()->None: await asyncio.sleep(1)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12868.py
Python
# test.py import ddtrace
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12874.py
Python
from .. import b class Object(): pass class ObjectFactory: def make_object(self) -> Object: pass OBJECT_FACTORY = ObjectFactory() from __future__ import annotations from . import my_directory def func(bar: Bar): print(bar.object) class Bar: def __init__( self, _: str, # if...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12876.py
Python
from dataclasses import dataclass from typing import Protocol, Dict, TypeVar, Generic class DataclassProtocol(Protocol): __dataclass_fields__: Dict T = TypeVar("T", bound=DataclassProtocol) @dataclass class MyDataclass: x: int = 1 class MyGeneric(Generic[T]): ... class MyClass(MyGeneric[MyDataclas...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12882.py
Python
from abc import ABCMeta from typing import Generic, TypeVar, Union class BaseEngine(metaclass=ABCMeta): pass class BaseEngineVariantA(BaseEngine): pass class BaseEngineVariantB(BaseEngine): pass class VariantAConcreteEngine(BaseEngineVariantA): pass CombinedTypes = Union[BaseEngineVariantA, Ba...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12885.py
Python
import typing from typing import Type T = typing.TypeVar("T") del typing # prevent accidental use below class MySuper: @classmethod def f(cls: Type[T]) -> T: return cls() class MySub(MySuper): @classmethod def f(cls: Type[T]) -> T: return super().f()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12887.py
Python
from typing import Generic, TypeVar NumericT = TypeVar('NumericT', int, float) class BaseThing(Generic[NumericT]): def put(self, x: NumericT): val = x + 'wrong' # ERROR: good, this is expected. class IntThing(BaseThing[int]): pass class FloatThing(BaseThing[float]): pass class StringTh...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12888.py
Python
T = TypeVar("T", bound=A) class Foo(Generic[T]): pass FooB = Foo[B]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12890.py
Python
from abc import ABC, abstractmethod class A(ABC): @property @abstractmethod def foo(self) -> str: ... class B(A): def foo(self) -> str: return "asdf" def get_foo(a: A) -> str: return a.foo b = B() # runtime error - AttributeError: 'function' object has no attribute 'capitalize' get_foo(...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12892.py
Python
class A: @property def foo(self) -> int: ... @foo.setter def foo(self, value: int, value2: str) -> None: # no mypy error ... a = A() a.foo = 1 # runtime error - TypeError: A.foo() missing 1 required positional argument: 'value2'
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12893.py
Python
class A: def __init__(*, self) -> None: ... a = A() # runtime error - TypeError: A.__init__() takes 0 positional arguments but 1 was given
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12894.py
Python
class A: @property def foo(self) -> int: ... @property # no error def foo(self, value: int) -> int: ... a = A()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12895.py
Python
from abc import ABC, abstractmethod class Foo(ABC): @abstractmethod @property def foo(self) -> int: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12897.py
Python
class A: ... b = 3.0 c = b / len(A()) reveal_type(c) class A: def __len__(self) -> int: return 0 b = 3.0 c = b / len(A()) reveal_type(c)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12899.py
Python
from typing import TypeVar Num = TypeVar("Num", bound=int | float) def add(a: Num, b: Num) -> Num: return a + b
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12900.py
Python
from typing import List, Iterable class Member: pass class Group: @property def members(self) -> List[Member]: pass @members.setter def members(self, members: Iterable[Member]) -> None: pass group = Group() group.members = {Member(), Member()} # mypy error: test.py:19: error:...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12904.py
Python
class A: @property def f(self) -> int: ... a = A() del a.f # no mypy error; runtime AttributeError
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12906.py
Python
@dataclass class MyModel: id: uuid name: str hostname: str memory_size: int # bad names Magic = SubsetTypedDict(MyModel, exclude=["id"], total=False) def wait_for_update(model_or_id: Model|uuid, **kw: Magic) -> Model: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12907.py
Python
from dataclasses import dataclass import collections @dataclass class Shadow: collections: collections.deque other: collections.defaultdict print(Shadow(collections.deque(), collections.defaultdict()))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12909.py
Python
from typing import Callable, TypeVar from typing_extensions import ParamSpec, Concatenate P = ParamSpec("P") T = TypeVar("T") def identity(func: Callable[P, T]) -> Callable[P, T]: def _wrapped(*args: P.args, **kwargs: P.kwargs) -> T: return func(*args, **kwargs) return _wrapped def int_identity(fu...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12915.py
Python
import random def foo() -> tuple[int, None] | tuple[int, str]: if random.choice((True, False)): return 0, None return 5, "thing" res = None status, res = foo() reveal_type(res) # builtins.str
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12919.py
Python
from typing import ( TypeVar, Protocol, Generic, Optional as Opt ) _T = TypeVar('_T') class _F(Protocol[_T]): def __call__(self, __x: _T) -> _T: ... # Lifting with a function... def lift(f: _F[_T]) -> _F[Opt[_T]]: # This function would do more, but I just return f for the # type ch...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12920.py
Python
def a() -> int | str: ... def b() -> str | None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12921.py
Python
from esbonio.lsp import LanguageFeature from esbonio.lsp.rst import CompletionContext, DefinitionContext, HoverContext from esbonio.lsp.sphinx import SphinxLanguageServer
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12922.py
Python
from typing import ParamSpec, TypeVar, Concatenate, Callable, overload P = ParamSpec("P") R = TypeVar("R") S = TypeVar("S") @overload def bar(x: Callable[Concatenate[S, P], R]) -> str: ... @overload def bar(x: Callable[P, R]) -> int: ... def bar(x: Callable[..., R]) -> str | int: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12923.py
Python
from typing_extensions import assert_type assert_type(42, int)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12924.py
Python
async def foo() -> Iterable[int]: async def bar(i: int) -> int: return i xs = [1, 2, 3] return (await bar(x) for x in xs) async def foo_errors() -> Iterable[int]: async def bar(i: int) -> int: return i xs = [1, 2, 3] for x in xs: v = awai...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12926.py
Python
import sys, winreg if sys.platform == "win32": winreg.QueryValueEx # Success: no issues found in 1 source file # mypy: platform=win32 import sys, winreg if sys.platform == "win32": winreg.QueryValueEx # test.py:5:5: error: Module has no attribute "QueryValueEx" [attr-defined]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12928.py
Python
from typing import TYPE_CHECKING from typing import TYPE_CHECKING as amogus if not TYPE_CHECKING: 1 + "" # no error (unreachable) if not amogus: 1 + "" # error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12929.py
Python
from typing import Union def a() -> Union[int, str]: ... def b() -> Union[str, None]: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12930.py
Python
from typing_extensions import ParamSpec from typing import Callable, TypeVar P = ParamSpec("P") R = TypeVar("R") def foo(func: Callable[P, R]) -> Callable[P, R]: def _inner(*args: P.args, **kwargs: P.kwargs) -> R: x = kwargs.pop("x") y = enumerate(args) return func(*args, **kwargs) ret...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12932.py
Python
from abc import ABC, abstractmethod from typing import Mapping, TypedDict PayloadType = Mapping[str, object] class ArgumentType(TypedDict): name: str class ReturnType(TypedDict): result: bool class IHandle(ABC): @abstractmethod def do_handle(self, name: PayloadType) -> PayloadType: ... cla...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12933.py
Python
class SupportsStr(Protocol): def __str__(self) -> str: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12934.py
Python
class TestDict(TypedDict): a: int def myfunc(test: dict): print(test) myfunc(TestDict(a=2))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12935.py
Python
import mypy.main as MAIN import mypy.build as BUILD from mypy.nodes import SymbolTableNode, Node, NodeVisitor py_file = "src/script_name" mod = py_file.replace("/", ".") files, opt = MAIN.process_options([f"{py_file}.py"]) opt.preserve_asts = True opt.fine_grained_incremental = True result = BUILD.build(files, optio...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12936.py
Python
from __future__ import annotations import typing as t HeaderValue = str | list[str] # HeaderValue = t.TypeVar("HeaderValue", str, list[str]) ResponseReturnType = tuple[str, dict[str, HeaderValue]] ViewCallable = t.Callable[..., ResponseReturnType] RouteCallable = t.TypeVar("RouteCallable", bound=ViewCallable) def rou...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12937.py
Python
from typing import Type class Abstract: def __init__(self, one): pass class A(Abstract): pass class B(Abstract): def __init__(self, one, two): pass MyClass: Type[Abstract] if 2 + 2 > 4: MyClass = A more_kwargs = {} else: MyClass = B more_kwargs = {"two": "two"} # cal...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12942.py
Python
class A: f: object class B(A): f: float b = B() a: A = b a.f = "abc" b.f.is_integer()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12944.py
Python
from icontract import ensure @ensure( lambda a, b, result: result == myadd(b, a), "Commutativity violated!" ) def myadd(a: int, b: int) -> int: return a + b from icontract import ensure @ensure( lambda a, b, result: result == myadd(b, a), # type: ignore "Commutativity violated!" ) de...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12945.py
Python
from __future__ import annotations import typing as t # ErrorBound = t.TypeVar("ErrorBound", bound=t.Type[Exception]) # HandlerCallable = t.Callable[[ErrorBound], None] HandlerCallable = t.Callable[[Exception], None] HandlerDecorator = t.TypeVar("HandlerDecorator", bound=HandlerCallable) def handler(code: t.Type[Exce...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12948.py
Python
T = TypeVar('T') S = TypeVar('S') class Foo(Generic[T]): pass def f(x: T) -> None: y: Foo[T] = Foo[T]() z = Foo[S]() # Type variable "S" is unbound # z: Foo[S] = Foo[S]() reveal_locals()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12949.py
Python
from typing import List class IntList(List[int]): pass T = TypeVar("T") def f(s: List[T]) -> T: reveal_type(s) if isinstance(s, IntList): reveal_type(s) s.pop() reveal_type(s) return s.pop()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12952.py
Python
from __future__ import annotations from typing import TypeAlias, TypeVar, get_args, TypeGuard A: TypeAlias = int | float d = (int,float) #T = TypeVar("T", int, float) # Correctly working if uncommented T = TypeVar("T", *d) #T = TypeVar("T", *get_args(A)) # Same results using this tuple of types instead of d def i...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2008.py
Python
from typing import Union x = 0 # type: Union[int, str] reveal_type(x) # Revealed type is 'Union[builtins.int, builtins.str]' x = 0 reveal_type(x) # Revealed type is 'builtins.int' x = "foo" # type: Optional[str] x + "bar" # E: Unsupported operand types for + ("Union[str, None]" and "str")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2044.py
Python
from typing import Generic, TypeVar, Set, List, Iterable T = TypeVar('T') class Node: def __init__(self, children: List['Node']) -> None: self.children = children def accept(self, visitor: 'Visitor[T]') -> T: pass class NodeChild(Node): def accept(self, visitor: 'Visitor[T]') -> T: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2073.py
Python
def name() -> str: ... if name: # Probably meant name()? do_something()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2087.py
Python
def some_function(x): ... some_function.some_attribute = 42 class FunctionForAdmin(Callable[[], Any]): short_description: str boolean: bool = False admin_order_field: str empty_value_display: str some_function: FunctionForAdmin def some_function(): return ... some_function.short_description = "Wha...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2103.py
Python
# mypy type_by_name (i: int) (path: str) # mypy type_by_pattern (is_* -> bool)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2190.py
Python
from django.db.models.fields import * # NOQA from django.db.models.fields.files import FileField, ImageField # NOQA
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2199.py
Python
from typing import * a = ['x', None] # type: List[Optional[str]] for i in range(len(a)): if a[i]: print(i, '<' + a[i] + '>') for i in range(len(a)): ai = a[i] if ai: print(i, '<' + ai + '>')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2255.py
Python
x = [[], [1]] for b in x: reveal_type(b) # error: Revealed type is 'builtins.object*' b + [1] # 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/2000-2999/2267.py
Python
class X: @staticmethod def f(): pass f()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2288.py
Python
#!/usr/bin/env python from typing import Any, Callable, Optional, TypeVar import socket, sys class CodedException(Exception): code = None # type: int class CommandLineError(CodedException): code = 3 T = TypeVar('T') def of_string_werr(fc # type: Callable[..., T] ): # type: (...) -> Callable[[Callable[[], Any...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2351.py
Python
T = TypeVar('T') TA = TypeVar('TA', bound='A') TC = TypeVar('TC', bound='C') class A: def f(self: T) -> T: ... # Should be error def g(self: TC) -> TC: ... # Should be error def h(self: TA) -> TA: ... # OK class C: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2388.py
Python
import threading _parameter_values = threading.local() _parameter_values.data = {} _parameter_values.data[3] = "hello" _parameter_values.data["hello"] = 3 import threading _parameter_values = threading.local() _parameter_values.data: Dict[int, str] = {} _parameter_values.data[3] = "hello"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2389.py
Python
from os.path import abspath def test1( x : List[str]) -> List[str] : # this is not working result = list(map(abspath, x)) # Line 5 return result # Line 6 def test2( x : List[str]) -> List[str] : # this is working return list(map(abspath, x))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2418.py
Python
class A(object): def do(self): from package import do_b # this gives an error # from package.b import do_b # this works return do_b(self) from package.a import A def do_b(a): # type: (A) -> str return 'foo' from .b import do_b from package.a import A a = A() print(a.do())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2427.py
Python
from typing import Any, Optional class Foo(object): def __init__(self): # type: () -> None self.x = 0 def get_x(self, a=None, b=None): # type: (Optional[int], Optional[int]) -> int return self.x + (a or 0) + (b or 0) def get_x_patch(self, *args, **kwargs): # type: (Foo,...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2455.py
Python
class Foo(object): def __init__(self, x): self.x = x def __eq__(self, other): if not isinstance(other, Foo): return NotImplemented return self.x == other.x set_of_foo = {Foo(1), Foo(2)}
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2464.py
Python
class Circle: radius: float class Rectangle: width: float height: float Shape = Union[Circle, Rectangle] def area(s: Shape) -> float: if isinstance(s, Circle): result = math.pi * s.radius**2 elif isinstance(s, Rectangle): result = s.width * s.height return result def area(s: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2499.py
Python
async def f() -> None: pass async def g() -> None: f()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2500.py
Python
class A: a = 1 class B(A): a = '' # Show that 'a' was defined in 'A' (in addition to the current message) class C(A): pass c = C() c.a = '' # Again, maybe show that 'a' was defined in 'A' class A: a = 1 def f(self) -> None: self.a = '' # The current message is probably just fine, as th...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2563.py
Python
# See http://stackoverflow.com/questions/3203286/how-to-create-a-read-only-class-property-in-python from typing import * T = TypeVar('T') V = TypeVar('V') class classproperty(Generic[T, V]): def __init__(self, getter: Callable[[Type[T]], V]) -> None: self.getter = getter def __get__(self, instance:...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2608.py
Python
def foo(arg=None): if arg is None: arg = {'bar', 'baz'} def func(arg=None): # type: (Dict[str, str]) -> Dict[str,str] reveal_type(arg) # Revealed type is 'Union[builtins.dict[builtins.str, builtins.str], builtins.None]' if arg is None: arg = {'foo': 'bar'} reveal_type(arg) # Reve...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2653.py
Python
class C(a=3): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2788.py
Python
s += 1 s: int = 0 x: int x += 1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2789.py
Python
x: int = 5 if True: global x x += 1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2800.py
Python
class C: def f(self, x: int) -> None: pass class D(C): def g(self, y: object) -> None: pass f = g # Incompatible types in assignment (expression has type Callable[[object], None], # base class "C" defined the type as Callable[[int], None]) class C: def f(self, x: int) -> None: pass class D...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2801.py
Python
import pymongo # this can be any third-party module without stubs Collection = pymongo.collection.Collection def func(a: Collection) -> bool: return True import pymongo def func(a: pymongo.collection.Collection) -> bool: return True
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2875.py
Python
from typing import Generic, TypeVar, NamedTuple T = TypeVar('T') class Node(Generic[T]): v: T class IntegerNode(Node[int], NamedTuple('IntegerNode', [('v', int)])): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2885.py
Python
from typing import TypeVar T = TypeVar('T') def f() -> T: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2900.py
Python
foo = dict(junk=1, bar=dict(yo=3)) foo['bar']['yo'] = 5
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2922.py
Python
class A(metaclass=abc.ABCMeta): pass class B: pass A.register(B) a: A = B() # currently E: Incompatible types in assignment (expression has type "B", variable has type "A") print(isinstance(a, A)) # -> True
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2928.py
Python
from typing import Any def f(x: Any) -> None: y = x y = 1 reveal_type(y) # Any
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2955.py
Python
import signal import sys signal.signal(signal.SIGTERM, lambda signum, stack: sys.exit(1))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2968.py
Python
from typing import Tuple from math import hypot Point = Tuple[float, ...] Centroid = Point def dist(p: Centroid, q: Point) -> float: px, py = p qx, qy = q return hypot(px - qx, py - qy) print( dist('xyz', (3.5, 7.2)) )
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/2000-2999/2980.py
Python
class A: a: Optional[int] b: Optional[int] ... def f(self) -> None: if None in (self.a, self.b): return print(self.a + self.b) # ok at runtime but mypy error currently
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3004.py
Python
import typing class A: @property def f(self) -> int: return 1 @f.setter # Possible error for defining a setter that doesn't accept the type the @property returns def f(self, x: str) -> None: pass a = A() a.f = '' # Possibly not an error, but currently mypy gives an error a.f = 1 # Cer...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3031.py
Python
T = TypeVar('T') def f(*x: T) -> Dict[int, T]: pass x = None if bool(): x = f() reveal_type(x) # E: Revealed type is 'builtins.None'
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3056.py
Python
class C(object): def __del__(self, a): # type: (int) -> int return a class C(object): def __del__(self): # type: () -> int return 0
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3060.py
Python
from typing import Type def f(x: Type[int]) -> None: if isinstance(x, Type): # Argument 2 to "isinstance" has incompatible type "object"; # expected "Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]" pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3115.py
Python
from abc import abstractmethod class Base: @abstractmethod def f(self) -> None: pass class A(Base): def f(self) -> None: pass class B(Base): def f(self) -> None: pass t = [A, B] t[0]() # Cannot instantiate abstract class 'Base' with abstract attribute 'f'
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3122.py
Python
x: Union[int, str] if isinstance(x, str): reveal_type(x) # Revealed type is 'builtins.str' x = x + 1 # E: Unsupported operand types for + ("str" and "int") reveal_type(x) # Revealed type is 'builtins.int' - CHANGED if isinstance(x, int): reveal_type(x) # Revealed type is 'builtins.int' x = x...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3123.py
Python
X = NamedTuple('X', [('x', int), ('y', str)]) X._make('a b')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3135.py
Python
decorator: int = 3 @decorator # no error class A: pass class B: pass NewB = decorator(B) # E: "int" not callable
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/3000-3999/3144.py
Python
T = TypeVar('T') class Outer(Generic[T]): class Inner: x: T # E: Invalid type "test.T" (correct) def f(self, x: T) -> T: ... # ok (incorrect) def g(self) -> None: y: T # E: Invalid type "test.T" (correct)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli