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/12445.py
Python
from typing import TYPE_CHECKING class A: ... class B: ... class C(A if TYPE_CHECKING else B): ... # error: Invalid base class [misc]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12446.py
Python
from typing import Literal dest: Literal["tata", "tutu"] for src in "tata", "tutu": dest = src t = "tata", "tutu" reveal_type(t) reveal_type(t.__iter__())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12447.py
Python
import dataclasses as dtc import typing as tp T = tp.TypeVar('T', int, str, covariant=True) @dtc.dataclass(frozen=True) class C(tp.Generic[T]): c: type[T] c_decision: dict[bool, C] = { True: C(int), False: C(str), } reveal_type(c_decision[True]) reveal_type(c_decision[False]) c_decision = { True: C...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12457.py
Python
from typing import Optional, Dict def test(arg: str) -> None: ... def this_fails(arg: Dict[str, Optional[str]]) -> None: if arg.get("key") is not None: test(arg["key"]) # error def this_fails_also(arg: Dict[str, Optional[str]]) -> None: if arg.get("key") is not None: test(arg.get("key")) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12458.py
Python
class InstrValCol(Col[ColKey, ValType], ColAttrsBase, metaclass=CacheMeta): ... class LookupResultTup(NamedTuple): status : RowKeyStatus value : Optional[ValType] = None def __repr__(self): repr = self.status.name if self.value is not None: repr += f' {self.value}' return repr
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12466.py
Python
import typing as t class A: @t.overload def pop(self) -> int: ... @t.overload def pop(self, d: int = ...) -> int: ... def pop(self, d: int = ...) -> int: ... class B(A): @t.overload def pop(self) -> int: ... @t.overload def pop(self, d: int) -> int: ... def pop(self...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12472.py
Python
import inspect foo = lambda: None foo.__signature__ = inspect.signature(foo)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12478.py
Python
from typing import List global_var = [1, 2, 3] global_var_annotated: List[int] = [1, 2, 3] reveal_locals() def foo(): local_var = [1, 2, 3] local_var_annotated: List[int] = [1, 2, 3] reveal_locals()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12483.py
Python
from enum import Enum value: Enum reveal_type(value) reveal_type(value.name)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12489.py
Python
from dataclasses import dataclass from typing import NamedTuple @dataclass class One: bar: int f: One reveal_type(f.__match_args__) # Revealed type is "Tuple[Literal['bar']]" class Two(NamedTuple): baz: str g: Two reveal_type(g.__match_args__) # Revealed type is "Tuple[Literal['baz']]"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12494.py
Python
import logging from enum import Enum class LoggedAccess: def __set_name__(self, owner, name): self.public_name = name self.private_name = '_' + name def __get__(self, obj, objtype=None): value = getattr(obj, self.private_name) logging.info('Accessing %r giving %r', self.public...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12497.py
Python
# temp.py import flask app = flask.Flask("name") @app.route("/") def home() -> flask.Response: return f""
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12500.py
Python
import dataclasses from typing import TypeVar, Generic class Parent: pass class Daughter(Parent): pass class Son(Parent): pass RestrictedChild = TypeVar("RestrictedChild", Daughter, Son) TupleChildrenX2 = tuple[RestrictedChild, RestrictedChild] @dataclasses.dataclass class ContainerWithAlias(Gener...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12501.py
Python
test = (1, 2) test += (3,) # error: Incompatible types in assignment (expression has type "Tuple[int, int, int]", variable has type "Tuple[int, int]") test: tuple[int, ...] = (1, 2) test += (3,)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12506.py
Python
from typing import Mapping, Hashable, Any, Union, Generic, TypeVar, overload, Dict S1 = TypeVar("S1") class A(Generic[S1]): # fails def myfun2(self, m: Union[Mapping[Any, Hashable], Hashable]): pass # Split the Union into two overloads works @overload def myfun3(self, m: Mapping[Any, Has...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12512.py
Python
# Code with imprecise lines from typing import TypedDict class UserDict(TypedDict): user_id: int # Marked imprecise email: str # Marked imprecise user:UserDict = { 'user_id': 1, 'email': 'you@somewhere.com' } # All lines are marked precise from typing import TypedDict UserDict = TypedDict('UserDict', {'user_i...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12523.py
Python
from enum import Enum class Example(str, Enum): ACCOUNT = "account" ACCOUNT_2 = "account_2" def t(self) -> None: print(example_map.get(self.value)) example_map = { Example.ACCOUNT: 1, Example.ACCOUNT_2: 2, } print(example_map.get(self)) example_map = { Example.ACCOUNT.value: 1...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12525.py
Python
from typing_extensions import Protocol class Func(Protocol): def __call__(self, __a: int, **kwargs: str) -> None: # ^^^ positional-only arg ... # Same error when using PEP 570 positional-only syntax: # def __call__(self, a: int, /, **kwargs: str) -> None: def myfunc(a: int, ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12527.py
Python
import dataclasses from typing import Generic, TypeVar T = TypeVar("T", bound="NotDefined") @dataclasses.dataclass class C(Generic[T]): x: float
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12535.py
Python
x = "a" reveal_type(x) assert x in ("a", "b", "c") reveal_type(x) y = 20 reveal_type(y) assert y == 10 or y == 20 or y == 50 reveal_type(y)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12544.py
Python
from dataclasses import dataclass from typing import TypeAlias class Foo: x = 1 @dataclass class A: ShortName: TypeAlias = Foo var: int = ShortName.x
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12545.py
Python
BLANK = "" SPECIAL = "asdf"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12553.py
Python
#!/usr/bin/env python3 import socket from enum import Enum from typing import Iterator, Type, TypeVar _E = TypeVar("_E", bound=Enum) def enum_iter(cls: Type[_E]): return iter(cls) for value in enum_iter(socket.SocketKind): print(value)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12557.py
Python
from typing import Callable, List def foo(factories: List[Callable[[], int]]): return sum(f() for f in factories) names = ["0", "abc"] # Inference works fine assert foo([lambda: len(name) for name in names]) == 4 # Cannot infer type of lambda assert foo([lambda name=name: len(name) for name in names]) == 4 def f...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12561.py
Python
from typing import Any, Callable class Foo: def __init__(self, a: int) -> None: print(a) def bar(f: Callable[[Any], Any]) -> None: if type(f) ==Foo: print("The same!") f(3) bar(Foo)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12563.py
Python
from pyparsing import Literal, Optional Literal("(") + Optional(Literal(")"))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12569.py
Python
from typing import Callable class Parent: foo: Callable[[str], str] class Child2(Parent): @staticmethod def foo(x: str) -> str: return x.lower() from typing import Callable class Parent: foo: Callable[[str], str] | str class Child1(Parent): foo = "bar" # OK class Child2(Parent): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12570.py
Python
from typing import Any @dataclass class C: dict:object # This attribute name shadows `dict` type, but it should not shadow the name inside of the `class` lexical scope; that's not how python works. d:dict # This attribute is annotated as `dict`. The interpreter does not pick up the previous shadowed attribute, but...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12573.py
Python
from typing import Optional, List class Foo: def __init__(self): self.bar: Optional[str] = None def barsplit(self) -> List[str]: if not self.bar: raise ValueError return self.bar.split() from typing import List, Optional, Callable from functools import wraps def require_b...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12575.py
Python
[tool.mypy] python_executable = ".venv/bin/python" plugins = ["pydantic.mypy"] # test.py import pydantic
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12580.py
Python
from typing import Optional import other_file import subfolder.file_in_subfolder same_folder_labeled:Optional[str] same_folder_labeled=other_file.labeled_return() same_folder_labeled.capitalize() same_folder_unlabeled:Optional[str] same_folder_unlabeled=other_file.unlabeled_return() same_folder_unlabe...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12583.py
Python
def foo(x: Literal[7]): pass var: Final = 3 + 4 foo(var)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12586.py
Python
from typing import Optional, TypeVar, Any T = TypeVar('T') def not_none(obj: Optional[T]) -> T: assert obj is not None return obj yy: Optional[Any] = "hello" not_none(yy).upper() # Mypy will complain here: `error: <nothing> has no attribute "parent"`
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12591.py
Python
P = ParamSpec("P") def foo(x: Callable[P, int], y: Callable[P, int]) -> Callable[P, bool]: ... def x_y(x: int, y: str) -> int: ... def y_x(y: int, x: str) -> int: ... foo(x_y, y_x) # Argument 1 to "foo" has incompatible type "Callable[[Arg(int, 'x'), Arg(str, 'y')], int]"; expected "Callable[[Arg(int, 'y'), Arg(str...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12593.py
Python
from functools import partial from typing import TypeVar, Callable from typing_extensions import ParamSpec, Protocol T = TypeVar('T', covariant=True) P = ParamSpec('P') class Wrapped(Protocol[P, T]): def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: pass def jit(f: Callable[P, T]) -> Wrapped[P, T]: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12594.py
Python
class A: def hello(self, a: str, b: str): pass world = hello class B(A): # Also tried without ":A" on the self argument def world(self: A, a: str, b: str): # Do something slightly different when child-class is the instance pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12595.py
Python
from typing import TypeVar, Callable from typing_extensions import Concatenate, ParamSpec, Protocol T_co = TypeVar('T_co', covariant=True) T = TypeVar('T') P = ParamSpec('P') class Wrapped(Protocol[P, T_co]): def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T_co: pass def jit(f: Callable[P, T], *, a: b...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12598.py
Python
class Foo: def foo(self) -> None: print("Foo!!!") class Bar: def __init__(self) -> None: self.foo: Foo | None = Foo() def get_rid_of_foo(self) -> None: self.foo = None bar = Bar() if bar.foo is not None: bar.get_rid_of_foo() assert bar.foo is None print(1 + "lol")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12599.py
Python
foo: str | None = None print(f"blah blah {foo}")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12610.py
Python
from typing import Dict from typing import Generic from typing import List from typing import Tuple from typing import TypeVar from typing import Union class Thing: pass _THING = TypeVar("_THING", bound="Thing") class ThingCollection(Generic[_THING]): _collection: List[Tuple[str, _THING]] _index: Dic...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12617.py
Python
from hypothesis import strategies as st st.lists(st.integers()).map(sorted) # error: Argument to "map" of "SearchStrategy" has incompatible type overloaded function; # expected "Callable[[List[int]], List[SupportsRichComparisonT]]" from typing import Callable, Generic, TypeVar Ex = TypeVar("Ex") T = TypeVar("T...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12621.py
Python
if my_obj.my_method: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12622.py
Python
from typing import Optional, TypeVar class Parent: def copy(self): return self MaybeParent = TypeVar("MaybeParent", bound=Optional[Parent]) def try_copy_works(parent: Optional[Parent]) -> Optional[Parent]: if parent is None: return None return parent.copy() def try_copy_doesnt_work(paren...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12629.py
Python
@dataclass class Order: # the Context customer: Customer cart: Sequence[LineItem] promotion: Optional[Callable[['Order'], float]] = None # the Strategy class Order(NamedTuple): customer: Customer cart: Sequence[LineItem] promotion: Optional[Callable[['Order'], float]] = None # the Strategy
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12633.py
Python
from dataclasses import dataclass from typing import Any, Callable, Generic, TypeVar T = TypeVar("T") @dataclass class Parent(Generic[T]): f: Callable[[T], Any] @dataclass class Child(Parent[T]): ... class A: ... def func(obj: A) -> bool: ... reveal_type(Child[A](func).f)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12637.py
Python
class Bar(Foo): pass # where Foo is undefined
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12641.py
Python
from collections import deque from typing import Any, Callable, Generic, List, Protocol, TypeVar T = TypeVar("T") def test(item_type: T) -> None: a: deque[List[T]] = deque() b: deque[List[T]] = a.copy() # ok class Test(Generic[T]): def test(self) -> None: a: deque[List[T]] = deque() b: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12642.py
Python
from typing import List, Protocol, Type class MyProto(Protocol): foo = List[str] class MyClass: foo = ["bar"] my_cls: Type[MyProto] = MyClass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12643.py
Python
from typing import Union Buffer = Union[bytes, bytearray, memoryview] def f(data: Buffer) -> str: if not isinstance(data, bytes): data = bytes(data) return data.decode() [tool.mypy] warn_unused_ignores = true show_error_codes = true strict = true
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12647.py
Python
from random import choice from typing import Literal, Union a: Union[Literal[1], Literal[2]] a = choice([1, 2]) # no error as expected a = choice((1, 2)) # Argument 1 to "choice" has incompatible type "Tuple[int, int]"; expected "Sequence[Union[Literal[1], Literal[2]]]" [arg-type]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12649.py
Python
def blocking_sleep(t: float) -> None: assert_no_running_loop() time.sleep(t) async def foo() -> None: blocking_sleep(10) from mypy_extensions import Blocking def blocking_sleep(t: float) -> Blocking[None]: assert_no_running_loop() time.sleep(t)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12651.py
Python
def fake_union(name: str, types: Tuple[Types, ...]) -> Union[Types]: ... UserErrors = (A, B) Response = fake_union(types=(User, *UserErrors), name="Response") def union_hook(ctx: DynamicClassDefContext) -> None: types_expr = ctx.call.args[ctx.call.arg_names.index("types")] assert isinstance(types_expr, ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12653.py
Python
T1 = TypeVar("T1") T2 = TypeVar("T2") T3 = TypeVar("T3") @dataclass class FunctionRelation(Generic[T1, T2, T3]): func1: Callable[[T1], T2] func2: Callable[[T2], T3] def func_str_int(x: str) -> int: return int(x) def func_int_str(x: int) -> str: return str(x) def func_str_str(x: str) -> str: retu...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12657.py
Python
def f(data: ByteString) -> str: if not isinstance(data, bytes): data = bytes(data) return data.decode()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12658.py
Python
TYPE_NONE = type(None) reveal_type(type(None)) # => `Type[None]` reveal_type(TYPE_NONE) # => `builtins.object`
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12665.py
Python
from typing import overload, Callable @overload def sub(pattern: str, repl: Callable[[str], str]) -> str: ... @overload def sub(pattern: bytes, repl: Callable[[bytes], bytes]) -> bytes: ... def sub(pattern: object, repl: object) -> object: raise NotImplementedError def better_snakecase(text: str) -> str: text...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12670.py
Python
from collections.abc import Iterator from contextlib import contextmanager class C: def __init__(self) -> None: self.x: None | int = None @contextmanager def f(self) -> Iterator[None]: self.x = None try: yield finally: if self.x is None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12672.py
Python
from typing import overload @overload def f(a: int) -> int: ... @overload def f(a: str) -> str: ... def f(a: int | str) -> bool | str: ... # E: Overloaded function implementation cannot produce return type of signature 1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12673.py
Python
from __future__ import annotations from typing import Callable def decorate(c: classmethod[None]) -> Callable[[X], None]: def g(x: X) -> None: return c.__func__(type(x)) return g class X: @decorate # error: Argument 1 to "decorate" has incompatible type "Callable[[Type[X]], None]"; expected "clas...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12677.py
Python
from typing import TypeVar import typing import typing_extensions U = TypeVar("U", int, typing_extensions.SupportsIndex) def f(si: U) -> U: return si def caller(si: typing.SupportsIndex): typing_extensions.assert_type(f(si), typing.SupportsIndex)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12682.py
Python
# filter-mypy.py path_parts: List[Optional[str]] = ["foo", None, "bar"] "/".join(filter(None, path_parts)) "/".join(filter(bool, path_parts)) "/".join(filter(lambda s: isinstance(s, str), path_parts)) class filter(Iterator[_T], Generic[_T]): @overload def __init__(self, __function: None, __iterable: Iterable[...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12687.py
Python
from typing import Generic, TypeVar T = TypeVar("T") class Animal(Generic[T]): pass class Pooh(Animal[T]): pass class Tigger(Animal[T]): pass def build_friend(animal_type: str) -> Animal[T]: friend_map = {constructor.__name__: constructor for constructor in (Pooh, Tigger)} return friend_map...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12689.py
Python
# pkg/lib.py # implicit re-exports import requests import requests as demands import requests.status_codes as requests_status_codes from requests import Request # implicit submodule re-export, but mypy doesn't care from requests import status_codes # pkg/shell.py from pkg.lib import requests, demands, requests_stat...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12690.py
Python
import logging stream_handler = logging.StreamHandler() file_handler = logging.FileHandler('output.txt') logger = logging.getLogger() for handler in (stream_handler, file_handler): logger.addHandler(handler)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12692.py
Python
sys.stdout.reconfigure(encoding='utf-8') sys.stderr.reconfigure(encoding='utf-8')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12694.py
Python
from dataclasses import dataclass from typing import Any, TypeVar T = TypeVar('T', bound='X') U = TypeVar('U', bound='Y') V = TypeVar('V', bound='Z') @dataclass class X: @classmethod def factory(cls: type[T], **kwargs: Any) -> T: return cls(**kwargs) @dataclass class Y(X): y: int @classmetho...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12697.py
Python
from pathlib import Path import subprocess import time # no type error code_1 = ''' from typing import Any def fib(n: int) -> int: if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) ''' # incorrect return type code_2 = ''' from typing import Any def fib(n: i...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12716.py
Python
def acquire(func: Callable[Concatenate[Any, str, _P], Awaitable[_T]]) -> Callable[Concatenate[Any, _P], Awaitable[_T]]: ... @overload async def get(self, key: bytes, default: None = ...) -> Union[bytes, _T, None]: ... @overload async def get(self, key: bytes, default: _U) -> Union[bytes, _T, _U]: ... @acqu...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12717.py
Python
class MyEnum: __members__: ClassVar[dict] = ... # read-only from typing import ClassVar class MyEnum: __doc__: ClassVar[str] = ... # read-only __members__: ClassVar[dict] = ... # read-only BAR: ClassVar[MyEnum] = ... FOO: ClassVar[MyEnum] = ... __entries: ClassVar[dict] = ... def __init...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12720.py
Python
NICE_LIST = [ (1, 2), (4, 5), ] BAD_LIST = [ (1, 2, 'I am bad'), (4, 5), ] PROCESS_NICE = [(x[1], range(x[0]), ['something' for _ in range(x[1])]) for x in NICE_LIST] PROCESS_BAD = [(x[1], range(x[0]), ['something' for _ in range(x[1])]) for x in BAD_LIST] reveal_locals()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12721.py
Python
from typing import * a: Final = 1 reveal_type(a) # Literal[1]? reveal_type(1) # Literal[1]?
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12725.py
Python
import discord
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12727.py
Python
from typing import overload, Callable @overload def f() -> None: ... @overload def f(fn: Callable[[], object]) -> None: ... def f(fn: object=1) -> None: ... x: object assert isinstance(x, str) y = x f(lambda: reveal_type(x)) # Revealed type is "str", Revealed type is "object" f(lambda: reveal_type(y)) # Revealed t...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12731.py
Python
from typing import Any, Generic, Optional, Type, TypeVar T = TypeVar("T") class customProperty(property, Generic[T]): def __get__(self, obj: Any, owner: Optional[Type] = None) -> T: return super().__get__(obj, owner) class C: @customProperty def prop(self) -> int: return 1 reveal_type(C(...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12732.py
Python
from typing import TypedDict class MyTypedDict(TypedDict, total=False): param1: int param2: str td: MyTypedDict = {"param1": 2, "param2": "foo"} td.pop("param1") td.clear() # The following options are set by the --strict command line flag warn_unused_configs=True disallow_any_generics=True disallow_subclass...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12733.py
Python
@overload def foo(cls: type[dict], mapping: SupportsKeysAndGetItem[K, V], /) -> dict[K, V]: ... @overload def foo(cls: type[dict], mapping: SupportsKeysAndGetItem[str, V], /, **kwargs: V) -> dict[str, V]: ... class FrozendictBase(Generic[K, V]): @overload def __new__( cls, mapping: Supp...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12734.py
Python
from typing import Callable, Concatenate, ParamSpec P = ParamSpec("P") Q = ParamSpec("Q") def foo(f: Callable[P, int]) -> Callable[P, int]: return f def bar(f: Callable[Concatenate[str, bool, Q], int]) -> Callable[Concatenate[str, bool, Q], int]: return foo(f)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12735.py
Python
from typing import Callable, Concatenate, ParamSpec from mypy_extensions import DefaultArg P = ParamSpec("P") def foo(f: Callable[P, None]) -> Callable[Concatenate[DefaultArg(int), P], None]: def g(n: int = 0, /, *args: P.args, **kwargs: P.kwargs) -> None: f(*args, **kwargs) return g
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12747.py
Python
def f(): print(x) x = 2 global x print(y) global y def f2(): x = y = 0 def g(): print(x) x = 2 nonlocal x print(y) nonlocal y
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12749.py
Python
# foo.py class Foo: ... # bar.py from foo import Foo # baz.py from bar import Foo # Module "bar" does not explicitly export attribute "Foo"; implicit reexport disabled [attr-defined] reveal_type(Foo) # Revealed type is "Any"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12754.py
Python
from typing import TypedDict def my_function(foo: int, bar: int, baz: str) -> None: pass class MyTypedDict(TypedDict, total=False): foo: int bar: int baz: str a: MyTypedDict = {'bar': 1} my_function(**a) # Should be error here, as a doesn't contain foo or baz
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12755.py
Python
from typing import TypedDict def my_function(foo: int, bar: int) -> None: pass class MyTypedDict(TypedDict): # foo: int bar: int a: MyTypedDict = {'bar': 1} my_function(**a) # mypy - error: Missing positional argument "bar" in call to "my_function" my_function(bar=1) # mypy - error: Missing positio...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12756.py
Python
class AbstractEventLoop: # Can't use a union, see mypy issue # 1873. @overload @abstractmethod def run_until_complete(self, future: Generator[Any, None, _T]) -> _T: ... @overload @abstractmethod def run_until_complete(self, future: Awaitable[_T]) -> _T: ... import asyncio import contextvar...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12757.py
Python
SeriesOfBool = NewType("SeriesOfBool", Annotated[pandas.Series, "bool"]) def is_series_of_bool(series: pandas.Series) -> TypeGuard[SeriesOfBool]: return series.dtype == "bool"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12758.py
Python
import abc class A: @abc.abstractclassmethod def foo(self) -> int: return 1 class B(A): def foo(self) -> int: return 2
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12759.py
Python
import asyncio from typing import Awaitable, Callable, TypeVar, overload, cast, Generic T = TypeVar("T", bound=object) class Async(Generic[T]): def __init__(self, f: Callable[[int], Awaitable[T]]): ... class Sync(Generic[T]): def __init__(self, f: Callable[[int], T]): ... @overload def su...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12760.py
Python
from typing import Set from zoneinfo import available_timezones x = {"UTC"} def error() -> Set[str]: return available_timezones() - set.union(x) def ok() -> Set[str]: a, b = available_timezones(), set.union(x) return a - b
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12774.py
Python
import attr from typing import Any def my_attr_s(cls, kw_only: bool = True) -> Any: # Added to attr_class_makers using "fake plugin". return attr.s(kw_only=kw_only)(cls) def my_attr_ib(**kwargs) -> Any: # Added to attr_attrib_makers using "fake plugin". return attr.ib(**kwargs) @my_attr_s class A: opti...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12779.py
Python
from flask import current_app from werkzeug.exceptions import abort as _wz_abort # current_app is annotated as `current_app: Flask` # Flask.aborter is an instance of werkzeug.exceptions.Aborter # Aborter.__call__ is annotated as `--> NoReturn` def abort(code: int, *args: Any, **kwargs: Any) -> NoReturn: reveal_ty...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12782.py
Python
# t.py def __() -> None: try: ... except ValueError as exc: e = exc else: e = None
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12783.py
Python
from typing import Iterable class X(Iterable[str]): ... a: Iterable[str] x: X b: bool if b: a = x or [] else: a = [""] reveal_type(a) # Revealed type is "Any" TypeOfAny.special_form a = x or [] if b else [""] reveal_type(a) # Revealed type is "list[str] | test.X | list[<nothing>]" from typing import Ite...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12785.py
Python
# Simulates a wrongly typed function in a types library (Redis get command) def wrong_type_get() -> str|None: return "abc" def get_int() -> int: value = wrong_type_get() assert isinstance(value, int) # type:ignore[unreachable] return value
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12786.py
Python
from typing import TypeVar Self = TypeVar("Self") class Flag: def __or__(self: Self, other: Self) -> Self: ... __ror__ = __or__ class IntFlag(int, Flag): def __or__(self: Self, other: int) -> Self: ... def __ror__(self: Self, other: int) -> Self: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12787.py
Python
from enum import ReprEnum, Flag class MyFlag(ReprEnum, Flag): ... from enum import Enum, Flag class ReprEnum(Enum): ... class MyFlag(ReprEnum, Flag): ... class ReprEnum(Enum): """ Only changes the repr(), leaving str() and format() to the mixed-in type. """ # Much further down... class IntFlag(int, Repr...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12795.py
Python
import typing class P(typing.Protocol): __name__: str def __call__(self) -> None: return def DEFAULT_P() -> None: ... def f(o: P) -> None: o() o.__name__ f(DEFAULT_P)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12799.py
Python
import datetime from typing import Any class MyDatetime(datetime.datetime): def __eq__(self, other: Any) -> bool: if isinstance(other, datetime.datetime): delta = self - other # error: No overload variant of "__sub__" of "datetime" matches argument type "datetime" [operator] delta...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12800.py
Python
from typing import TypeVar, Union T = TypeVar("T", bound=Union[str, int]) def a(x: T) -> T: if isinstance(x, str): return x return x
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12802.py
Python
def f(x: Optional[X]) -> None: if isinstance(x, Y): print(x.bar()) from typing import Optional, Protocol, runtime_checkable from typing_extensions import reveal_type class X: def foo(self) -> int: ... @runtime_checkable class Y(Protocol): def bar(self) -> int: ... class Z(X): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12806.py
Python
from contextlib import asynccontextmanager from dataclasses import dataclass from typing import ( AsyncContextManager, AsyncIterator, Callable, Generic, ParamSpec, TypeVar, ) _Input = ParamSpec("_Input") _Result = TypeVar("_Result") @dataclass class Foo(Generic[_Input, _Result]): func: Ca...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/12000-12999/12823.py
Python
from typing import Optional class Cat: pass class Dog: pass class MyClass: def __init__(self) -> None: self.pet: Optional[Dog | Cat] = None def get_pet(self) -> Optional[Dog | Cat]: if input() == 'yes': self.pet = Cat() else: self.pet = Dog() ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli