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/12113.py
Python
import dataclasses import typing if typing.TYPE_CHECKING: import classb as b ItemType = typing.TypeVar('ItemType', bound='b.ClassB') class Item(typing.Protocol): name: str class ItemBase(typing.Generic[ItemType]): pass # dataclasses required to trigger bug. @dataclasses.dataclass(kw_only=True) clas...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12115.py
Python
from typing import TypeVar, Type, Callable, Union, Any # t1 is a non-union type t1: Type[bool] = bool # t2 is a union type t2: Union[Type[bool], Type[str]] = bool # T1 is bound by a single Union type (supertype of bool and str) T1 = TypeVar("T1", bound=Union[bool, str]) def foo1(t: Type[T1]) -> None: ... foo1(t1) # ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12120.py
Python
class Math: @property def learn(self): return ""
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12123.py
Python
from typing import Optional class Test: def double(self, x: int) -> int: return x * 2 def check_value(a: Optional[Test], b: Optional[int]) -> Optional[int]: if None in (a, b): return None return a.double(b) if __name__ == '__main__': check_value(Test(), 2)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12126.py
Python
from typing import Callable, Any, TypeVar T = TypeVar('T', bound='BaseClass') # Alternative Example class BaseClass: def default_example(self) -> list[int]: return [1, 2, 3] example: Callable[[Any], list[int]] | list[int] = default_example class ChildClassA(BaseClass): example: list[int] =...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12130.py
Python
import random from typing import ( Type, ) # CASE ONE (works as expected): str_type_1: Type[str] = str reveal_type(str_type_1) # Revealed type is "Type[builtins.str]" # CASE TWO (unexpected behaviour): str_type_2: Type[str] reveal_type(str_type_2) # Revealed type is "Type[builtins.str]" str_type...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12137.py
Python
from dataclasses import dataclass @dataclass class A: a: int = 0 @dataclass class B(A): a: int b: str
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12139.py
Python
foo: int = 1 def bar() -> None: foo foo = 2
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12140.py
Python
from typing import Protocol class A(): def __init__(self, x: int) -> None: pass class B(Protocol): def __call__(self) -> None: pass def run(obj: B) -> None: obj() def main() -> None: x = A run(x) if __name__ == '__main__': main()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12141.py
Python
import os for component in os.uname(): print(component.encode())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12143.py
Python
class A(TypedDict): """Empty""" a: A = {} reveal_type(a.get("foo", None))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12144.py
Python
import numpy as np print(np.concatenate((np.array([1]), [2])))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12146.py
Python
a: object if isinstance(a, list): reveal_type(a) # list[Any] b = a[0] # Any
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12147.py
Python
from typing import Any a: Any a = {1: 2} # error: Expression type contains "Any" (has type "Dict[Any, Any]")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12151.py
Python
T = TypeVar("T") A_no_T = TypeVar( "A_no_T", bound="A[None]", ) class A( Generic[T], ): @overload def method( self: A_no_T, ) -> None: pass @overload def method( self, t: T, ) -> None: pass def method( self, t: Optional...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12155.py
Python
import numpy as np x = "a" assert isinstance(x, np.float64) from numpy import float64 x = "a" assert isinstance(x, float64)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12156.py
Python
import typing as t T = t.TypeVar('T') U = t.TypeVar('U') def coalesce(a: T | None, b: U) -> t.Union[T, U]: if a is None: return b return a def foo() -> int: return coalesce(42, None)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12157.py
Python
class Some(Enum): a = 1 b = 2 _ignore_ = ('a',) reveal_type(Some.a) # E: "Type[Some]" has no attribute "a"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12158.py
Python
from typing import final @final class A: b: int if A(): print("hi") # no unreachable error print(A() and "hi") from typing import final @final class A: b: int a: A | None r1: int | None = a.b if a else None r2: int | None = a and a.b # error: Incompatible types in assignment (expression has type...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12160.py
Python
import sys import mypy mypy.util.check_python_version("stubgen") options = mypy.stubgen.Options( pyversion=sys.version_info[:2], no_import=False, doc_dir="", search_path="", interpreter="", ignore_errors=False, include_private=False, output_dir="out", modules=[], packages=["gdb"], files=[], ve...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12162.py
Python
follow_imports = "silent" ignore_missing_imports = true namespace_packages = true exclude = "(.venv|...other stuff...)"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12163.py
Python
from typing import TypeVar, final @final class A: def __init__(self,value: str) -> None: ... @final class B: def __init__(self,value: int) -> None: ... T = TypeVar("T", A, B) def foo(cls: type[T]) -> T: if issubclass(cls, A): return cls("") # error: Argument 1 to <subclass of "B" and "A"> has i...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12164.py
Python
from typing import final from abc import ABC, abstractmethod class Foo(ABC): @final @abstractmethod def foo(self) -> None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12165.py
Python
from typing import TypeGuard, _T, Callable class Sus: def fake_tasks(sus, where: str) -> None: ... def is_sus(it: object) -> TypeGuard[Sus]: ... def run(fn: Callable[[object], _T]) -> None: ... run(is_sus) # error: Argument 1 to "run" has incompatible type "Callable[[object], TypeGuard[Sus]]"; expected "Callab...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12166.py
Python
from typing import TypeGuard, _T, Callable class Sus: def fake_tasks(sus, where: str) -> None: ... def is_sus(it: object) -> TypeGuard[Sus]: ... def run(fn: Callable[[], _T]) -> _T: ... crewmate: int if run(lambda: is_sus(crewmate)): crewmate.fake_tasks("medbay") # int" has no attribute "fake_tasks"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12169.py
Python
from typing import TypeVar, Generic, ParamSpec, Protocol, Callable from functools import partial T = TypeVar("T", covariant=True) P = ParamSpec("P") class JittedFunction(Protocol, Generic[P, T]): def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ... def lower(self) -> int: ... def jit(fun: Cal...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12172.py
Python
class Translation: def __init__(self, message: str): self.message = message def __str__(self) -> str: translate = _ if translate is Translation: return self.message return translate(self.message) @classmethod def install(cls): import builtins builtins._ = cls Translation.install() s = _('somethi...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12178.py
Python
import inspect import mymod inspect.signature(mymod.MyClass.method1) # or help(mymod.MyClass) # correctly prints (a,b,c) class Myclass: @classmethod def __init__(cls, *args, **kwargs) -> None: ... def method1(self, *args, **kwargs) -> Any: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12183.py
Python
from dataclasses import dataclass from typing import Generic, Protocol, TypeVar import pandas as pd _DataFrameBound = TypeVar("_DataFrameBound", bound=pd.DataFrame, covariant=True) class _Method(Protocol[_DataFrameBound]): def __call__(self, dataframe: pd.DataFrame) -> _DataFrameBound: ... @dataclass ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12186.py
Python
from dataclasses import dataclass @dataclass class Foo: ... reveal_type(Foo.__eq__) # Revealed type is "def (builtins.object, builtins.object) -> builtins.bool"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12190.py
Python
if m := re.search(pattern, string): return m.group(group) m = re.search(pattern, string) if m: return m.group(group)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12196.py
Python
import foo foo.foo("") def foo(i: int) -> None: 1 + ""
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12200.py
Python
class Permissive(TypedDict, total=False): id: str class Restrictive(TypedDict): id: str def convert(d: Restrictive) -> Permissive: return cast(Permissive, d) python_version = "3.9" namespace_packages = true explicit_package_bases = true strict = true
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12206.py
Python
def f(*, x: int = 9, y:int = 8) -> None: pass kwargs = {"x": 1, "y": 2} f(*kwargs)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12208.py
Python
class Animal: name: Literal["animal"] n_legs: int class Plant: name: Literal["plant"] def get_n_legs(item: Union[Animal, Plant]): if item.name == "animal" and item.n_legs > 6: # This fails mypy with union-attr for n_legs in Plant return "Many"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12211.py
Python
_ResponseType = TypeVar("_ResponseType") SyncFunc: TypeAlias = Callable[..., _ResponseType] Coro: TypeAlias = Callable[..., Coroutine[Any, Any, _ResponseType]] SyncFuncOrCoro: TypeAlias = Coro[_ResponseType] | SyncFunc[_ResponseType] _ResponseType = TypeVar("_ResponseType") SyncFunc: TypeAlias = Callable[..., _R...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12215.py
Python
from typing import * def foo() -> Iterable[Union[Tuple[Literal["foo"], int], Tuple[Literal["bar"], str]]]: for i in range(10): if i % 2 == 0: yield "foo", i else: yield "bar", str(i)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12224.py
Python
from typing import Union class A: def __init__(self, a): ... Test1 = str | A # error Test2 = Union[str, A]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12228.py
Python
from typing import overload, Protocol, runtime_checkable from collections.abc import Sequence class Foo: def func(self, a: int) -> float: ... class FooOverload: @overload def func(self, a: int) -> float: ... @overload def func(self, a: str) -> Sequence[float]: ... @runtime_checkable class Support...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12247.py
Python
f = filter(lambda ch: chr(ch), b"hello") bytes(f) bytes(filter(lambda ch: chr(ch), b"hello"))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12252.py
Python
class FieldCategory(IntEnum): """ Names used to prefix the capture group name for a field. The enum's name is used to get a value of that category for a Body, or the substring of its name. The enum's value is used to sort display of multiple FieldGroups in the same Col. """ bnk = auto() num = auto() off = auto()...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12256.py
Python
def f(i) -> None: ... def f2(i): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12259.py
Python
# src/foobar/app.py from .widgets import BlueWidget, RedWidget, Widget, WidgetSpec class App: def make_widget(self, spec: WidgetSpec) -> Widget: if spec.color == "red": return RedWidget(app=self, spec=spec) elif spec.color == "blue": return BlueWidget(app=self, spec=spec) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12261.py
Python
from typing import Protocol class Foo(Protocol): ... Foo() from typing import Protocol class Foo(Protocol): def __init__(self) -> None: pass Foo() # disallowed class ConcreteFoo(Foo): ... ConcreteFoo() # allowed
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12265.py
Python
@object.__new__ class A: ... class B: ... reveal_type(A) reveal_type(B)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12268.py
Python
from typing import Union, List class A: pass class B: pass class Base: variable1 : List[Union[A, B]] = [] variable2 : List[Union[A, B]] = [] class Derived(Base): variable1 = [A()] variable2 = variable1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12270.py
Python
from typing import TypedDict class A(TypedDict): x: int a: A a.__setitem__('x', '') # no error b: int = a.__getitem__('x') # error: Incompatible types in assignment (expression has type "object", variable has type "int")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12271.py
Python
from typing import TypedDict class A(TypedDict): x: int a: A a.setdefault('x', '') # test.py:6:1: error: Argument 2 to "setdefault" of "TypedDict" has incompatible type "str"; expected "int"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12272.py
Python
C = C
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12274.py
Python
from typing import List, ParamSpec P = ParamSpec('P') def foo(x: List[P]) -> None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12278.py
Python
from typing import Callable, ParamSpec, TypeVar T = TypeVar("T") P = ParamSpec("P") R = TypeVar("R") def call(f: Callable[P, R], *args: P.args, **kwargs: P.kwargs) -> R: return f(*args, **kwargs) def identity(x: T) -> T: return x call(identity, 2) # error: Argument 2 to "call" has incompatible type "int";...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12285.py
Python
reveal_type not_defined reveal_type
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12286.py
Python
import sys if sys.version_info < (3, 11): print(21 + "sus") # very funny, but is a type error 😢 if sys.platorm == "win32": print(21 + "sus") # very funny, but is a type error 😢 [tool.mypy] platforms = ["lignux", "darwin", "win32"] python_versions = [3.11, 3.10, 3.9, 3.8, 3.7]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12290.py
Python
from typing import Any class A: pass B: Any # (Or from untyped_lib import B) m: Any if isinstance(m, (A, B)): reveal_type(m) else: reveal_type(m)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12292.py
Python
from abc import ABCMeta, abstractmethod from typing_extensions import overload, ParamSpec from typing import TypeVar, Sequence, Optional, Callable PResourceParams = ParamSpec('PResourceParams') TResource = TypeVar('TResource', bound='Resource', covariant=True) # Multiple implementations of Resource will exist, but # ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12297.py
Python
# test_case.py from typing import Callable, Optional, TypeVar, Union, overload class Foo: pass class Bar: pass ReturnsFooOrBarT = Callable[..., Union[Foo, Bar]] TermT = TypeVar("TermT", bound=ReturnsFooOrBarT) def returns_foo() -> Foo: return Foo() def returns_bar() -> Bar: return Bar() @overload def do_s...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12299.py
Python
import discord 1 + "2"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12300.py
Python
from typing import TypeVar T = TypeVar("T", int, str) def foo(cls: type[T]) -> T: ... asdf: type reveal_type(type) # error: Expression type contains "Any" a = foo(asdf) # no error reveal_type(a) # int
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12301.py
Python
d: dict # error l: list # error s: set # error t: type # no error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12310.py
Python
from typing import Type, TypeVar, TypedDict T = TypeVar("T") def f(cls: Type[T]) -> T: return cls() class Foo(TypedDict): pass f_foo: Foo = f(Foo) reveal_type(f(Foo))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12313.py
Python
import _editable_pkg_typed from editables.redirector import RedirectingFinder as F F.install() F.map_module('editable_pkg_typed', '/path/to/package/editable_package_typed/__init__.py') INSTALLER LICENSE METADATA RECORD REQUESTED WHEEL { "url": "file:///path/to/package", "dir_info": { "editable": true...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12314.py
Python
class L: a: int class R: b: int class Both(L, R): pass class A: @property def x(self) -> L: ... class B: @property def x(self) -> R: ... class C(A, B): # error: Definition of "i" in base class "A" is incompatible with definition in base class "B" pass both: L = Both() assert isin...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12316.py
Python
l: list[()][int]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12325.py
Python
from typing import Literal def foo(a: Literal[True]) -> None: ... FOO: bool foo(FOO) # error: Argument 1 to "foo" has incompatible type "bool"; expected "Literal[True]" [arg-type] reveal_type(FOO) # note: Revealed type is "builtins.bool" if not FOO: pass reveal_type(FOO) # note: Revealed type is "Litera...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12326.py
Python
from typing import NamedTuple, Optional class Foo(NamedTuple): bar: int = 0 baz: str = "" class MyClass(): __slots__ = ['var1', 'var2', 'var3'] def __init__(self, foo: Optional[Foo] = None) -> None: self._reset_state() if foo: self.var3 = foo def _reset_state(self) ->...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12327.py
Python
from typing import _T class A:... class B(A): a: int class C(A): a: int def safe(it: _T | None) -> _T:... b_or_c: B | C value = safe(b_or_c) reveal_type(value) #A, should be B | C value.a # error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12328.py
Python
from typing import Protocol, cast class FooType(Protocol): def __call__(self, ham: str) -> str: pass def foo(ham: str) -> str: pass v = cast(FooType, foo) u: FooType = foo
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12337.py
Python
from typing import * class C(Protocol): T = TypeVar('T') def __call__(self, t: T) -> T: ... def f(t: int) -> int: return t g: C = f # mypy crashes here from typing import * class C(Protocol): T = TypeVar('T') def foo(self, t: T) -> T: ... class D: def foo(self, t): r...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12341.py
Python
from typing import ( # ignore currently needs to be here Union, DoesNotExist, # type: ignore[error attr-defined] ) def foo(bar:int) -> str: ... def baz() -> int: ... a = ( # type: ignore[call-arg] "something" if baz() > 0 else foo() # ignore currently needs to be here ) # formatters (eg. black)...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12342.py
Python
# mypy: disable-error-code=name-defined python-verion="3.6" a # error: Name "a" is not defined [name-defined] [[tool.mypy.overrides]] module = ["test"] disable_error_code = "name-defined" python_verion="3.6" # mypy: AMONGUS
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12344.py
Python
from typing import Protocol class MixinProt(Protocol): def func(self) -> None: ... class Mixin: def func(self: MixinProt) -> None: return super().func()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12354.py
Python
# a.py import b b.f() # b.py def f() -> None: pass # b.py (2) def f(x) -> None: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12360.py
Python
from __future__ import annotations from typing import Protocol class P(Protocol): def f(self) -> int: ... class C: def f(self) -> int: return 5 class D: def f(self) -> int: return 6 x: tuple[P, ...] = () reveal_type(x) x = (C(), D()) reveal_type(x) for thing in x: print(thing.f())...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12361.py
Python
import abc from typing import Callable class A(abc.ABC): @abc.abstractmethod def m(self) -> None: ... class C(A): def m(self) -> None: pass def f() -> A: return C() def t(x: Callable[[], A]) -> None: x() def main() -> None: t(f) t(C) t(A) # should give typing e...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12365.py
Python
# mypy: always-true=foo from typing import Literal foo: bool if not foo: print(1) # no error ✅ bar: Literal[True] if not bar: print(1) # error: Statement is unreachable ✅ # mypy: always-true=foo from typing import Literal foo: bool def f1() -> None: if foo: return print(1) # error: Sta...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12368.py
Python
a: None | int b = None | int # error: Unsupported left operand type for | ("None") [operator]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12369.py
Python
from typing import Any print(reveal_type(int | Any)) # types.UnionType from typing import Any isinstance(1, str | Any) # no error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12370.py
Python
from typing import Any isinstance(1, str | Any) # no error, fails at runtime with TypeError: typing.Any cannot be used with issubclass()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12372.py
Python
class A: def foo(self) -> int: pass class B(A): def foo(self) -> str: pass # type: ignore[override] class C(B): def foo(self) -> str: pass class ChoiceField(Field): def to_python(self, data: Optional[Any]) -> str: ... class ModelChoiceField(ChoiceField): def to_python(self, data: Optional[Any])...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12377.py
Python
import enum class A(enum.Enum): X = 'x' def f(v: A): pass f(A.X)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12379.py
Python
from typing import overload, Union class A: def f(self, x: Union[int, str]) -> None: ... class B(A): @overload def f(self, x: int) -> None: ... @overload def f(self, x: str) -> None: ... def f(self, x: Union[int, str]) -> None: ... arg: Union[int, str] B().f(arg)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12382.py
Python
from typing import TypeAlias A: TypeAlias = "str" isinstance(1, A) # no error reveal_type(A) # type[str]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12385.py
Python
# test.py from typing import Generic, Type, TypedDict, TypeVar _TA = TypeVar("_TA") _TB = TypeVar("_TB") class GenericBase(Generic[_TA, _TB]): type_a: Type[_TA] type_b: Type[_TB] A = TypedDict("A", {}) B = TypedDict("B", {}) class GenericChild(GenericBase[A, B]): type_a = A type_b = B
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12386.py
Python
from typing_extensions import ParamSpec from typing import Callable P = ParamSpec("P") def foo(func: Callable[P, None]): def _inner(*args: P.args, **kwargs: P.kwargs): x = kwargs.pop("x")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12387.py
Python
from __future__ import annotations from typing import ( Callable, Literal, TypeVar, overload, ) F = TypeVar("F", bound=Callable) def deprecate() -> Callable[[F], F]: ... NDFrameT = TypeVar("NDFrameT", bound="NDFrame") class NDFrame: @overload def drop(self, inplace: Literal[True]) ->...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12392.py
Python
from typing import Type, TypeAlias A = type[int] | str # error: Value of type "Type[type]" is not indexable B = Type[int] | str # error: Unsupported left operand type for | ("object") C: TypeAlias = type[int] | str # error: Value of type "Type[type]" is not indexable D: TypeAlias = Type[int] | str # error: Unsuppo...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12393.py
Python
from typing import Callable, TypeAlias A = Callable[[], str] | int # error: Unsupported left operand type for | ("object") B: TypeAlias = Callable[[], str] | int # error: Unsupported left operand type for | ("object") C = int | Callable[[], str] # No error using Python 3.10 (in a `.py file), or in a stub file on a...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12397.py
Python
from typing import type_check_only, ParamSpec, Concatenate, Callable @type_check_only # no warning about unsupported functionality def foo() -> None: ... P = ParamSpec("P") def bar(func: # error: The first argument to Callable must be a list of types or "..." Callable[ Concatenate[P, int], None, ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12401.py
Python
from typing import overload @overload def foo(a: int) -> int: ... @overload def foo(a: float) -> int: ... def foo(a: object) -> object: # no error return object()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12402.py
Python
from typing import overload, NoReturn @overload def f(a: str) -> int: ... @overload def f(a: str, b: NoReturn) -> NoReturn: ... def f(a: str, b: NoReturn = ...) -> object: ... b: bool assert b if not b: f("") # error: Statement is unreachable ✅ print("hi") if not b: f("", b) # error: Statement ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12405.py
Python
def func(o: object) -> None: if o: ... # error: "o" has type "object" which does not implement __bool__ or __len__ so it could always be true in boolean context [truthy-bool]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12409.py
Python
import sys def foo() -> None: assert sys.platform == "AMONGUS" a # error, reachable ❌ cond: bool if cond: assert sys.platform == "AMONGUS" a # error, reachable ❌ assert sys.platform == "AMONGUS" a # no error, silent unreachable ✅
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12413.py
Python
from typing import List, Optional my_list: List[Optional[float]] = [] if my_list[0] is not None: result_1: float = my_list[0] # no error result_2: float = my_list[1] # error: Incompatible types in assignment (expression has type "Optional[float]", variable has type "float") id_0 = 0 if my_list[...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12414.py
Python
import uuid class Bar: uuid: uuid.UUID = uuid.uuid4() reveal_type(Bar().uuid)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12425.py
Python
class A: pass B = type(A)('B', (A,), {}) b = B()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12433.py
Python
from typing import Protocol from unittest.mock import create_autospec from abc import abstractmethod class A(Protocol): @abstractmethod def method(self) -> int: raise NotImplementedError class Error: # if commenting this class pass # mypy works without complains def test_one() -> N...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12439.py
Python
from typing import TYPE_CHECKING if TYPE_CHECKING: from . import MediaType class FileFormatError(Exception): pass class MediaTypeValueError(FileFormatError): def __init__(self, value): super().__init__(f'{value!r} is not a valid media type.') class UnsupportedFileFormatError(FileFormatError): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12440.py
Python
from typing import Optional class Base: description: Optional[str] class MixinWDesc: description: str class SubClass(MixinWDesc, Base): description: str class SomeOtherMixin: pass # succeeds class ImplementsWOMixin(SubClass): pass # fails class ImplementsWMixin(SomeOtherMixin, SubClass): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12441.py
Python
class A: pass from dataclasses import dataclass from a import A @dataclass class B(A): c: str
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12442.py
Python
check_untyped_defs = true disallow_incomplete_defs = true disallow_untyped_calls = true disallow_untyped_defs = true show_error_codes = true
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli