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/9000-9999/9901.py
Python
from collections import namedtuple class EmployeeRecord(namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')): def is_junior(): return self.age < 18 from typing import NamedTuple class EmployeeRecord(NamedTuple): name: Any age: Any title: Any department: Any paygrade: Any def is_junio...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9908.py
Python
from typing import Literal, get_args class Ham: HamLiteral = Literal["foo"] class DHam(Ham): pass ham_literal_args = get_args(Ham.HamLiteral) # note: Revealed type is 'builtins.tuple[Any]' ham_literal_args_fails = get_args(DHam.HamLiteral) # mypy: error: INTERNAL ERROR print(ham_literal_args, ham_literal_...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9910.py
Python
from typing import Final, final class Parent: __foo: Final[int] = 0 @final def __bar(self) -> None: pass class Child(Parent): __foo: Final[int] = 1 # error: Cannot override final attribute "__foo" (previously declared in base class "Parent") @final # error: Cannot override final attrib...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9911.py
Python
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal class FeatureModel(QObject): stateChanged = pyqtSignal() def __init__(self, enabled: bool, /) -> None: super().__init__() self._enabled = enabled @pyqtProperty(bool, notify=stateChanged) def enabled(self): return sel...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9913.py
Python
from typing import Any, Callable, overload, TypeVar T = TypeVar('T') U = TypeVar('U') @overload def tree_map(f: Callable[[U], U], tree: T) -> T: ... @overload def tree_map(f: Callable[[T], U], tree: T) -> U: ... @overload def tree_map(f: Callable[[Any], Any], tree: Any) -> Any: ... def tree_ma...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9914.py
Python
class ProgressLogger(NamedTuple): progress: Callable[[T], T] def bar(progress_logger: ProgressLogger) -> None: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9929.py
Python
from typing import Callable, Generic, TypeVar T_co = TypeVar("T_co", covariant=True) class Foo(Generic[T_co]): def __init__(self, bar: Callable[[T_co], None]) -> None: self.bar = bar def good(self) -> "Foo[T_co]": return Foo(self.bar) def bad(self) -> "Foo[T_co]": # error here ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9932.py
Python
from typing import List foo: "List"[int] = [1] # Accepted by mypy but generates runtime error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9934.py
Python
import types class Cls: def meth(self): pass assert isinstance(Cls.meth, types.FunctionType) # no problem x: types.FunctionType = Cls.meth
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9937.py
Python
from typing import (ClassVar, Generic, NamedTuple, Optional, Type, TypeVar, Union, overload) BoundsInt = NamedTuple("BoundsInt", [ ("begin", int), ("end", int)]) BoundsStr = NamedTuple("BoundsStr", [ ("begin", str), ("end", str)]) _T = TypeVar("_T", int, str) class MyContainerBase(Gener...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9938.py
Python
from typing import Dict class MyObject(str): """ >>> tuple(MyObject('G')) ('G', 71) """ def __iter__(self): return iter((self, ord(self))) def get_mapping() -> Dict[str, int]: """ >>> get_mapping() {'a': 97, 'b': 98} """ items = MyObject('a'), MyObject('b') return...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9947.py
Python
@icontract.ensure(lambda result: (result[0] is None) ^ (result[1] is None)) def some_func() -> Tuple[Optional[str], Optional[str]]: ... return something, errors ... result, errors = some_func() if errors is not None: ... # We know here according to the contract that ``result`` can not be None.
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9962.py
Python
x = ((1, 'a', 1.4),) for _, _, y in x: print(y) import pkgutil from somemod import _plugins # trigger an import of all of the plugins # https://github.com/python/mypy/issues/1422 plugins_path: str = _plugins.__path__ # type: ignore mod_infos = pkgutil.walk_packages(plugins_path, f'{_plugins.__name__}.') for _,...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9972.py
Python
import importlib_metadata
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9986.py
Python
from dataclasses import dataclass @dataclass(order=True) class Dummy: foo: str bar: int from typing import Any class Dummy: foo: str bar: int def __init__(self, foo: Any, bar: Any) -> None: ... def __lt__(self, other: Any) -> Any: ... def __gt__(self, other: Any) -> Any: ... def __le_...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9987.py
Python
gearIcon = QIcon(str('...')) menuSettings: QMenu = self.menuBar().addMenu('&Tools') actionSettings = menuSettings.addAction(gearIcon, '&Settings') actionSettings.triggered.connect(self.showSettingsDialog) @typing.overload def addAction(self, arg__1:PySide6.QtGui.QAction) -> None: ... @typing.overload def addAction(sel...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9991.py
Python
from typing import * x: Optional[int] = None y: Optional[int] = None def f() -> None: x = 1 y = 1 class C: reveal_type(x) # Correctly reveals int reveal_type(y) # Incorrectly reveals int, should be Optional[int] x = 2
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/9000-9999/9998.py
Python
from typing import Union def f() -> Union: print('hello hello') def g() -> Union[()]: print('hello hello')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/1269.py
Python
from docutils import nodes def hello(node): # type: (nodes.Node) -> None pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/1467.py
Python
# _txt_fmt is a object gotten from `re.compile` with open(file, 'r+') as f: with mmap.mmap(f.fileno(), 0) as data: match = _txt_fmt.match(data)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2093.py
Python
print(cfg.get('Section1', 'monster', fallback=None))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2333.py
Python
import urllib.request from typing import Optional resp = urllib.request.urlopen('https://example.com') x: Optional[str] = resp.headers['connection']
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2383.py
Python
from typing import List, Optional x: List[Optional[int]] = [1, 2, 3] [None] + x
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2477.py
Python
from six.moves import urllib from typing_extensions import TYPE_CHECKING if not TYPE_CHECKING: def reveal_type(ignored): pass _, frg = urllib.parse.urldefrag("https://github.com/python/typeshed/#typeshed") print(type(frg)) reveal_type(frg) _, frg2 = urllib.parse.urldefrag(u"https://github.com/python/type...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2527.py
Python
import io import sys class C(io.BufferedIOBase): pass def test(c: io.BufferedIOBase): assert isinstance(c, io.BufferedIOBase) test(sys.stdout.buffer) test(C())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2652.py
Python
import asyncio from typing import List async def five() -> int: return 5 async def runner() -> List[int]: fives = await asyncio.gather(five(), five(), five()) print(type(fives)) # prints `<class 'list'>` print(fives) # prints `[5, 5, 5]` return fives loop = asyncio.get_event_loop() result: List...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/2772.py
Python
import contextlib from typing import Iterator @contextlib.contextmanager def f() -> Iterator[int]: return iter([1]) with f(): pass with f(): raise TypeError('wat')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/3363.py
Python
import subprocess class MyPopen(subprocess.Popen): def __init__(self) -> None: args = ['echo', 'test'] super().__init__( args=args, )
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/3404.py
Python
import multiprocessing q = multiprocessing.Queue() q.join()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/3438.py
Python
from collections import Counter spam = Counter() spam["egg"] += 3.4
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/3551.py
Python
from typing import Dict, Union d: Dict[Union[str, int], None] = {} e: Dict[str, None] = {} # not ok d.update(e) # ok d.update(e.items()) # ok for key, value in e.items(): d[key] = value
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/3556.py
Python
# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's # not exposed anywhere under that name, we make it private here. class ellipsis: ... Ellipsis: ellipsis
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/3576.py
Python
from typing import Iterator, Mapping class MyMap: def __getitem__(self, key: str) -> int: return 0 def __iter__(self) -> Iterator[str]: return iter([]) def __len__(self) -> int: return 0 def __contains__(self, key: object) -> bool: return False def foo(x: Mapping[str, i...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4054.py
Python
#! /usr/bin/env python import re m = re.match(u"(?P<key1>[01]+)", u"100 abc") if m is not None: d = m.groupdict() print(type(list(d.items())[0][0])) print(d.get(u"key1", u"default"))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4234.py
Python
from urllib.parse import urlencode, quote args_dict = {'a': 'b'} urlencode(args_dict, quote_via=quote)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4362.py
Python
h = hashlib.sha1() pickle.dumps(obj, protocol=5, buffer_callback=h.update)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4545.py
Python
{'_abc', '_asyncio', '_blake2', '_bz2', '_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', '_codecs_tw', '_collections', '_collections_abc', '_contextvars', '_crypt', '_ctypes', '_curses_panel', '_datetime', '_dbm', '_elementtree', '_functools', '_gdbm', '_hashlib', '_io', ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4641.py
Python
zxcvbn pyspark psutil pymongo setuptools python-future pyzmq pynput z3 pony
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4731.py
Python
class A: @cached_property def f(self) -> int: # f is `cached_property[int]`, f.__get__() -> int ... @property def g(self) -> int: # f is `property[Any]`, g.__get__() -> Any ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4837.py
Python
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer def forty_two() -> int: return 42 def echo_int(value: int) -> int: return value class EchoInt(object): def __call__(self, value: int) -> int: return value def main() -> None: xml_rpc_server = SimpleXMLRPCServer( ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/4849.py
Python
def cached( cache: Optional[MutableMapping[_KT, _VT]], key: Callable[..., _KT] = ..., lock: Optional[ContextManager[_T_co]] = ... ) -> Callable[[_T], _T]: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5402.py
Python
__match_args__: Final[Tuple[Literal["left"], Literal["op"], Literal["right"]]] __match_args__: Final = ("left", "op", "right")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5491.py
Python
import gzip import tarfile open('t', 'w').close() with gzip.GzipFile('out.tar.gz', 'wb') as gzipf: with tarfile.open(fileobj=gzipf, mode='w') as tf: tf.add('t')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5493.py
Python
@overload def open(mode: Literal["r"] = ...) -> int: ... @overload def open(mode: Literal["w"]) -> str: ... @overload def open(mode: str) -> str | int: ... mode: str = ... open(mode)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5560.py
Python
T = TypeVar("T") @singledispatch def my_fun( val: T, ) -> List[T]: return list(val) my_fun(5) my_fun("Ĝis la revido!")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5755.py
Python
from docutils.parsers.rst import directives
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5779.py
Python
class _FlowControlMixin(Transport): def __init__(self, extra: Optional[Mapping[Any, Any]] = ..., loop: Optional[AbstractEventLoop] = ...) -> None: ... def get_write_buffer_limits(self) -> Tuple[int, int]: ... class WriteTransport(BaseTransport): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/5910.py
Python
JsonObject = dict[str, Any] # Any is Json JsonArray = list[Any] # Any is Json Json = JsonObject | JsonArray | str | float | int | bool | None
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6061.py
Python
# repro.py import typing from io import TextIOWrapper, BufferedIOBase def badfunc(stream: BufferedIOBase) -> TextIOWrapper: return TextIOWrapper(stream) def goodfunc(stream: typing.IO[bytes]) -> TextIOWrapper: return TextIOWrapper(stream)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6069.py
Python
@overload def __new__(cls) -> Literal[False]: ... @overload def __new__(cls: Type[_T], __o: object) -> _T: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6153.py
Python
import subprocess process = subprocess.Popen("echo hello", shell=True, stdout=subprocess.PIPE) assert process.stdout is not None print(process.stdout.read1())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6240.py
Python
from google.protobuf.wrappers_pb2 import StringValue StringValue(value=some_obj.var_a) some_string_field_in_proto_Message = StringValue(value=some_obj.var_a) if some_obj.var_a is not None else None
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6303.py
Python
pow(complex(1), 2, 2) # no type error? pow(float(1), 2, 2) # still no type error? from numbers import Complex my_complex: Complex = complex(1) # type: ignore [assignment] # see 3186 pow(my_complex, 2, 2) # No overload variant of "pow" matches argument types "Complex", "int", "int"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6597.py
Python
from typing import Mapping, Any, Optional x: Optional[Any] m: Mapping[str, int] m.get(x) # error: Argument 1 to "get" of "Mapping" has incompatible type "Optional[Any]"; expected "str"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6820.py
Python
from configparser import RawConfigParser cfg = RawConfigParser() cfg.add_section("default") cfg.set("default", "some_option1", True) r1 = cfg.get("default", "some_option1") print(r1, type(r1)) cfg.set("default", "some_option2", 1) r2 = cfg.get("default", "some_option2") print(r2, type(r2)) cfg.set("default", "some...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6893.py
Python
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/6987.py
Python
import functools from typing import TypeVar _T = TypeVar("_T") def my_func(elem: _T) -> list[_T]: return [elem] my_func_cached = functools.lru_cache(my_func) a = my_func("a") reveal_type(a) # Revealed type is "builtins.list[builtins.str*]" a_c = my_func_cached("a") # ERROR: this should be "builtins.list*...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7077.py
Python
import socket import sys print(sys.platform) s = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, socket.NETLINK_ROUTE) print(s)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7121.py
Python
names: set[str] = {"a", "b"} name: str | None = None names.discard(name)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7217.py
Python
from numbers import Real def test(f: Real) -> Real: return f test(1.32) # error: Argument 1 to "test" has incompatible type "float"; expected "Real"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7258.py
Python
import logging class C: def __init__(self) -> None: self.level = logging.INFO def enable_debug(self) -> None: # Error: expression has type "Literal[10]", variable has type "Literal[20]" self.level = logging.DEBUG import logging class Base: level = logging.INFO class Derived(Base...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7436.py
Python
_T = TypeVar("_T", str, bytes) class Formatter(Generic[_T]): @overload def __init__(self: Formatter[str], *, encoding: None = ..., outencoding: None = ..., **options) -> None: ... @overload def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = ..., **options) -> None: ... @over...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7505.py
Python
from typing import Union print(isinstance(1, Union[str, int])) # error: Argument 2 to "isinstance" has incompatible type "object"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7516.py
Python
class A: @property def foo(self): return 'a' A.foo.fget(A())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7542.py
Python
from unittest import mock import subprocess def foo() -> None: with mock.patch.object( subprocess, "Popen", **{"return_value.communicate.side_effect": KeyboardInterrupt} ): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7550.py
Python
def maximum_possible_date_anywhere_on_earth(instant: Optional[datetime] = None) -> date: """ The largest possible date that any human on earth could legitimately claim to be "today". Basically whatever day the UTC+14 people are on. """ if instant is None: instant = now() return max( ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7559.py
Python
import argparse class CSVCallback(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, list(values.split(','))) parser = argparse.ArgumentParser() parser.add_argument('-o', action=CSVCallback, default=[]) args = parser.parse_args() def csv_ca...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7564.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/typeshed/7574.py
Python
sum("hello")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7576.py
Python
import collections.abc class MyView(collections.abc.KeysView): def __iter__(self): for key in self._mapping: yield key + 1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7579.py
Python
foo = sum([True, False]) foo += 1 @overload def sum(__iterable: Iterable[_SumT]) -> _SumT | Literal[0]: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7674.py
Python
_TypeT = TypeVar("_TypeT", bound=type) _Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] # ... dispatch_table: dict[type, Callable[[type], str | _Reduce[type]]] # undocumented import copyreg import pickle class Foo: __slots__ = ("conta...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7689.py
Python
P = ParamSpec('P') class classmethod(Generic[P, _R_co]): @property def __func__(self) -> Callable[P, _R_co]: ... @property def __isabstractmethod__(self) -> bool: ... def __init__(self: classmethod[_R_co], __f: Callable[P, _R_co]) -> None: ... def __get__(self, __obj: _T, __type: type[_T] | None...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7698.py
Python
import tkinter c = tkinter.Canvas() c.pack() c.create_polygon([(10, 20), (130, 40), (50, 100)]) tkinter.mainloop()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7735.py
Python
V = t.TypeVar("V") def sync_do_sum( environment: "Environment", iterable: "t.Iterable[V]", attribute: t.Optional[t.Union[str, int]] = None, start: V = 0, # type: ignore ) -> V: if attribute is not None: iterable = map(make_attrgetter(environment, attribute), iterable) return sum(itera...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7739.py
Python
from __future__ import annotations from functools import partialmethod class A: def my_add(self, other: A, reverse: bool) -> A: return self __add__ = partialmethod(my_add, reverse=False) a = A() aa = A() aaa = A() result = sum([aa, a], start=aaa)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7762.py
Python
# TODO: Type this more accurately # Vec2D is actually a custom subclass of 'tuple'. Vec2D: TypeAlias = tuple[float, float] # Python 3.10.1; mypy 0.950 from turtle import Vec2D # Vec2D is a class and a type alias v1 = Vec2D(1,1) # mypy doesn't recognize it as callable v2 = v1.rotate(90) # illustrate that Vec2D has me...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7770.py
Python
import xml.etree.ElementTree as ET tree = ET.ElementTree() print(tree.getroot()) # prints None class ElementTree: def __init__(self, element=None, file=None): # assert element is None or iselement(element) self._root = element # first node if file: self.parse(file) def get...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7775.py
Python
from typing import TYPE_CHECKING if TYPE_CHECKING: from hashlib import _Hash def f(h: "_Hash") -> None: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7776.py
Python
s = requests.Session() s.hooks['response'].append(print_url)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7813.py
Python
enumerate iter str.join bytes.__new__ bytes.join
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7833.py
Python
old_factory = logging.getLogRecordFactory() def record_factory(*args, **kwargs): record = old_factory(*args, **kwargs) record.custom_attribute = 0xdecafbad return record logging.setLogRecordFactory(record_factory) import logging custom_contextual_data = "XYZ" def main() -> None: logging.basicConfi...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7840.py
Python
import tempfile with tempfile.NamedTemporaryFile() as file: reveal_type(file) # tempfile._TemporaryFileWrapper[builtins.bytes] file.asdfasdf # no error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7843.py
Python
import tempfile from typing import BinaryIO my_var: BinaryIO = tempfile.NamedTemporaryFile()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7904.py
Python
from typing import TypeAlias Recursive: TypeAlias = str | list["Recursive"] def foo(r: Recursive) -> None: if not isinstance(r, str): foo(r[0]) if not isinstance(r, list): r.casefold() foo("") foo(list("")) foo(list(list(""), ""))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7921.py
Python
import io stream = io.TextIOWrapper(io.BytesIO(b'"")\r\nx\r\n')) stream.read(1) stream.read(1) stream.read(1) print('-----> tell:', stream.tell()) def _upgrade_high_scores_file(file: IO[str], old_version: int) -> None: ... file.seek(len(b"catris high scores file v")) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7930.py
Python
import hmac import hashlib hmac.digest(b"123", b"msg", hashlib.sha256) # 3: error: Argument 3 to "digest" has incompatible type "Callable[[Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData]], DefaultNamedArg(bool, 'usedforsecurity')], _Hash]"; expected "str" [arg-type]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7946.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/typeshed/7947.py
Python
loader = yaml.SafeLoader loader.add_constructor( "!ReplaceWithConfig", partial(replace_with_config_constructor, config=config) )
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7953.py
Python
import csv from io import StringIO csvtext = "foo,bar\n1,2\n3,4,5" csvreader = csv.DictReader(StringIO(csvtext), delimiter=',') #def checkrow(row: dict[str | None, str]) -> None: def checkrow(row: dict[str, str]) -> None: if None in row: print(f"None found as key with value {row[None]!r}, someone broke a promise!...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7961.py
Python
# ctx.py from contextlib import ExitStack class Thing(ExitStack): def foo(self) -> None: print("foo") stack = ExitStack() thing = stack.enter_context(Thing()) reveal_type(thing) thing.foo()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/7998.py
Python
url = 'https://httpbin.org/post' multiple_files = [ ('images', ('foo.png', open('foo.png', 'rb'), 'image/png')), ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))] r = requests.post(url, files=multiple_files) r.text
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/8009.py
Python
from typing import TypeVar, TypeGuard T = TypeVar('T') def iscoroutinefunction(func: T) -> TypeGuard[T]: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typeshed/8030.py
Python
# Must be defined by user __getitem__ __setitem__ __delitem__ __len__ insert # Defined in Sequence __contains__ __iter__ __reversed__ index count # Defined in MutableSequence append reverse extend pop remove __iadd__ __len__ __getitem__ __setitem__ __delitem__ append extend insert remove
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typing/1009.py
Python
P = ParamSpec("P") R = TypeVar("R") def foo(f: Callable[P, R]) -> Callable[P, List[R]]: # Here, the parameters are actually P + optional kw-only int x = 3 def inner(*args: P.args, x: int = 3, **kwargs: P.kwargs) -> List[R]: results = [] for _ in range(x): ret = f(*args, **kwargs) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typing/1039.py
Python
np = load_numpy() # def load_numpy() -> ??: x = np.array(123) # << I want to have auto-complete & type checking here if typing.TYPE_CHECKING: import numpy as np def load_numpy() -> Literal[np]: import numpy as np return np
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typing/1043.py
Python
import argparse parser = argparse.ArgumentParser(description="My parser") parser.add_argument("--my_bool", type=bool) print(parser.parse_args()) # Error: statement is unreachable import argparse parser = argparse.ArgumentParser(description="My parser") parser.add_argument("--my_bool", type=bool) # Error: type=bool d...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typing/1096.py
Python
def my_open(name: str, write: bool): with open(name, 'wb' if write else 'rb') as f: content = f.read() if typing.STRICTER_STUBS: AnyOrUnion = typing.Union else: AnyOrUnion = typing.Any
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typing/1112.py
Python
class A: @property def foo(self): return 'a' A.foo.fget(A())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/typing/1129.py
Python
class TypingFeatures: PARAMSPEC_SUPPORTED = ... VARIADIC_SUPPORTED = ... LITERAL_STRING_SUPPORTED = ... if TypingFeatures.PARAMSPEC_SUPPORTED: def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, ContextManager[_T]]: ... else: def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli