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
src/views.rs
Rust
use crate::client::log_for_client; use crate::client::Client; use crate::escapes::Color; use crate::escapes::KeyPress; use crate::game_logic::game::Mode; use crate::game_wrapper; use crate::game_wrapper::GameStatus; use crate::game_wrapper::HighScoresStatus; use crate::high_scores::GameResult; use crate::ingame_ui; use...
Akuli/catris
2
The classic game of falling blocks, but with online multiplayer
Rust
Akuli
web-ui/index.html
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CATRIS</title> <script src="javascript.js"></script> <link rel="stylesheet" href="style.css"> </head> <body> <div id="terminal-container"> <div id="terminal"></div> <pre id="cursor-overlay"></pre> </div> <div id="c...
Akuli/catris
2
The classic game of falling blocks, but with online multiplayer
Rust
Akuli
web-ui/javascript.js
JavaScript
document.addEventListener("DOMContentLoaded", () => { const COLORS = { // taken from mate-terminal with a color picker program '30': {fg: '#555753'}, '31': {fg: '#EF2929'}, '32': {fg: '#8AE234'}, '33': {fg: '#FCE94F'}, '34': {fg: '#729FCF'}, '35': {fg: '#AD7FA8'}, '36': {fg: '#34E2E2'}...
Akuli/catris
2
The classic game of falling blocks, but with online multiplayer
Rust
Akuli
web-ui/style.css
CSS
body { background-color: #333; color: white; /* Used when displaying the disconnected message after quitting */ } #terminal-container { display: grid; font-family: monospace; } #terminal, #cursor-overlay { grid-area: 1 / 1; /* https://stackoverflow.com/a/55475793 */ padding: 0.2em; border: 0px; bord...
Akuli/catris
2
The classic game of falling blocks, but with online multiplayer
Rust
Akuli
ghbackup.py
Python
from __future__ import annotations import argparse import re import sys from typing import Any from datetime import datetime, timezone, timedelta from collections.abc import Iterator from pathlib import Path import requests session = requests.Session() # These are optional, but GitHub recommends setting them sessio...
Akuli/ghbackup
2
Local backups of GitHub issue/PR comments
Python
Akuli
tests.sh
Shell
#!/bin/bash # When any command fails, tests stop with a failure set -e GREEN="\x1b[32m" RESET="\x1b[0m" while [ $# != 0 ]; do case "$1" in --no-colors) GREEN="" RESET="" shift ;; *) echo "Usage: $0 [--no-colors]" exit 2 ...
Akuli/himmeli
0
Blue light filter written in Jou
Shell
Akuli
code_snippets/mypy/0-999/230.py
Python
from typing import List, TypeVar T = TypeVar('T') def f(a: List[T], b: List[T]) -> None: pass x = [''] f(x, []) # Cannot infer type argument 1 of "f"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/240.py
Python
class A: def f(self) -> None: self.x = 1 A.x = 1 # accepted, but should be an error class A: x = 1 A.x = 1 # ok, and should be ok
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/327.py
Python
import typing try: x = WindowsError except NameError: x = None
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/363.py
Python
def __lt__(self, x: int) -> bool: if isinstance(x, int): return ... return NotImplemented def f() -> bool: return NotImplemented
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/495.py
Python
from typing import Callable, Union, overload def f(fn: Callable[[Union[int, str]], Union[int, str]]) -> None: pass @overload def g(x: int) -> int: ... @overload def g(x: str) -> str: ... def g(x): ... f(g) # Currently error
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/538.py
Python
import typing x = 'Hagar Qim' def f() -> None: global x, y x = 1 # Type error reported y = 2 # Ignored y = 'Mnajdra'
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/61.py
Python
import b name = 'a' print(b.name) import a name = 'b' print(a.name)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/685.py
Python
S = TypeVar("S") T = TypeVar("T") class Pair(Generic[S, T], NamedTuple("Pair",[ ('fst', S), ('second', T)])): def show(self): print(self.fst, self.second) p = Pair("ab", 22) # type: Pair[str, int]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/686.py
Python
def f(x: A): pass y = A() class A: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/687.py
Python
a = A() class A: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/708.py
Python
from typing import Callable class A: f = None # type: Callable[[int], int] def __init__(self, g: Callable[[int], int]) -> None: self.f = g f = None # type: Callable[[int], int] def g(x: int) -> int: return 0 f = g
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/731.py
Python
Callback = Callable[[str], 'Callback'] Foo = Union[str, List['Foo']]
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/734.py
Python
T = TypeVar('T', covariant=True) class A(Generic[T]): def foo(self, x: T) -> None: ... # Can't use as argument type! Return type is okay.
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/736.py
Python
IV = TypeVar('IV') CV = TypeVar('CV', covariant=True) class A(Generic[IV]): ... # Bunch of methods class B(A[CV], Generic[CV]): pass # Error, type variable should be invariant
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/737.py
Python
CV = TypeVar('CV', covariant=True) class A(Generic[CV]): def foo(self) -> List[CV]: ... # Error, should be # Sequence[CV] or similar, since List is invariant
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/857.py
Python
class A: def __init__(self, a): pass class B(A): def __init__(self, a): super(B, self).__init__(a) self._inner = super(B, self)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/941.py
Python
class A: pass class B: pass class A: pass class B(A): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/0-999/963.py
Python
from typing import AnyStr def f(x: AnyStr, y: AnyStr) -> AnyStr: print(x + y) f('one', b'two')
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1006.py
Python
def foo(): @staticmethod def bar(): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1013.py
Python
class A: def f(self, x): ... class B(A): def f(self, xx): ... def f(a: A) -> None: a.f(x=1) # Failure if a is an instance of B f(B())
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1021.py
Python
class C(object): def __new__(cls, foo=None): obj = object.__new__(cls) obj.foo = foo return obj x = C(foo=12) print(x.foo)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1052.py
Python
class A: def __setattr__(self, x, y): raise RuntimeError
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1065.py
Python
# FIX: Currently we should only have one supertype per interface, so no # need to return an array [...] # FIX: Currently we might only ever have a single path, so this could be # simplified
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1069.py
Python
def outer(cls): class C(cls): # E: Invalid type "cls" def meth(self): super(C, self).meth() # E: "meth" undefined in superclass cls = ... class C(cls): # E: Invalid type "cls" def meth(self): super(C, self).meth() # E: "meth" undefined in superclass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1106.py
Python
if x: m = None else: import m
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1152.py
Python
@contextmanager def simulated_queue_client(client): real_SimpleQueueClient = queue_processors.SimpleQueueClient queue_processors.SimpleQueueClient = client yield queue_processors.SimpleQueueClient = real_SimpleQueueClient
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1153.py
Python
try: import simplejson except ImportError: import json as simplejson
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1170.py
Python
def foo(): pass foo.csrf_exempt = True
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1178.py
Python
from typing import Any, Dict, Tuple, Union VarTuple = Union[Tuple[int, int], Tuple[int, int, int]] def make_tuple(): # type: () -> VarTuple return None x = make_tuple() a = b = c = 0 if len(x) == 3: a, b, c = x else: a, b = x c = 0
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1184.py
Python
@contextmanager def disable_errors(self) -> None: self.disable_count += 1 yield self.disable_count -= 1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1188.py
Python
if True: from pycurl import Curl, version_info else: from mock import Mock Curl = Mock() version_info = Mock()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1193.py
Python
foo = 0 foo += 0.5
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1314.py
Python
class C(metaclass=ABCMeta): @classmethod def foo(cls) -> None: cls().bar() @abstractmethod def bar(self): raise NotImplementedError C.foo() # not cool class D(C): def bar(self): pass D.foo() # this is fine
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1317.py
Python
from typing import * from contextlib import * T = TypeVar("T") @contextmanager def foo(x): # type: (T) -> Iterator[T] yield x y = 1 with foo(2) as f: y = f
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1362.py
Python
class Foo(object): @property @some_decorator def foo(self): ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1393.py
Python
try: from inspect import isawaitable # py35+ except ImportError: from backports_abc import isawaitable
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1424.py
Python
if hasattr(x, 'initialize'): x.initialize() if hasattr(x, 'initialize'): cast(Any, x).initialize()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1465.py
Python
class Config(object): @property def my_proprty(self): return None def _other(self): pass @my_proprty.setter def my_proprty(self, val): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1484.py
Python
from typing import * from functools import partial def inc(a:int) -> int: return a+1 def foo(f: Callable[[], int]) -> int: return f() foo(partial(inc, 1))
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1506.py
Python
from typing import TypeVar, Callable S = TypeVar('S') def apply(f: Callable[[int], S]) -> S: pass def g(x: int) -> S: pass y = apply(g) reveal_type(y) # E: Revealed type is 'S`-1'
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1507.py
Python
from typing import TypeVar, Callable S = TypeVar('S') def apply(f: Callable[[int], S]) -> S: pass def g(x: S) -> S: pass y = apply(g) # E: Argument 1 to "apply" has incompatible type Callable[[S], S]; expected Callable[[int], S] reveal_type(y) # E: Revealed type is 'S`-1' tokenprog, pseudoprog, single3prog, double3pro...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1509.py
Python
def f() -> None: return g() # oops, but no error def g(): return 1
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1533.py
Python
from typing import AnyStr, Union def g(a: AnyStr) -> AnyStr: pass def f(a: Union[str, bytes]): g(a)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1555.py
Python
class X(IntEnum): x = 'x' # mypy doesn't complain
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1561.py
Python
from typing import Generic, Optional, Tuple, TypeVar # Would like to write bound='TypedCons[T, V]' here, where T is self-referential T = TypeVar('T', bound='TypedCons') V = TypeVar('V') class TypedCons(Generic[T, V]): def __init__(self, value: V, cdr: Optional[T]=None) -> None: self.value = value...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1573.py
Python
from itertools import groupby from typing import Iterator, Iterable, TypeVar, Callable, Tuple, Any X, Key = TypeVar('X'), TypeVar('Key') def sorted_groupby(sequence: Iterable[X], key: Callable[[X], Key]) -> Iterator[Tuple[Key, Iterator[X]]]: return groupby(sorted(sequence, key=key), key=key)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1655.py
Python
from typing import Callable def test_func(a, b, c=0, d=0): # type: (int, int, int, int) -> int return a + b + c + d def check_func(method): # type: (Callable[[int, int, int], int]) -> int return method(1, 2, d=5) print(check_func(test_func)) from typing import Callable def test_func(a, b, *, c, d):...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1683.py
Python
def f(): class C: return
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1685.py
Python
class A('B'): pass class B: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1735.py
Python
def f(): pass y = 1 if f(): y = None # None not compatible with int reveal_type(y) if f(): z = 1 else: z = None # None not compatible with int reveal_type(z)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1831.py
Python
from typing import Type class A: def __init__(self, x: int) -> None: pass def f(t: Type[object]) -> None: t() # ok, since `object()` is valid f(A) # no error reported! class A: ... @classmethod def f(cls: Type[[int], A]) -> A: return cls(1) # ok
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1882.py
Python
import six if six.PY2: n = 42 def main(): # type: () -> None if six.PY3: print("n is only defined on python 2.") else: print("n =", n) # ... some number crunching on n import six if six.PY2: n = 42 def main(): # type: () -> None if six.PY3: print("n is on...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1997.py
Python
def f(*a): # type: (int) -> None pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/1000-1999/1998.py
Python
class Apple(object): ... T_co = TypeVar('T_co', covariant=True) A_co = TypeVar('A_co', bound=Apple, covariant=True) class Action(Generic[T_co]): ... class AppleAction(Generic[A_co], Action[A_co]): ... if isinstance(action, AppleAction): reveal_type(action)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10003.py
Python
from __future__ import annotations from typing import TypeVar, Union import numpy T = TypeVar("T") def _test(a: list[T]) -> Union[numpy.ndarray, T]: if isinstance(a[0], str): return a[0] return numpy.array(a)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10004.py
Python
import json import pathlib import tempfile import textwrap import time from mypy import api def generate_n_overloads(n: int, types=('str', 'int', 'float')) -> str: result = ['import typing'] for name_count in range(n): type_name = types[name_count % len(types)] name = f'overload_{name_count}...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10007.py
Python
from typing import TypedDict class C(TypedDict): a: {"c": int}
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10008.py
Python
from __future__ import annotations from collections.abc import Mapping from typing import Any, cast, TYPE_CHECKING def test(one: int | None = None, **kwargs: Any) -> int | None: print(repr(kwargs)) return one if TYPE_CHECKING: reveal_type(test) reveal_type(test()) reveal_type(test(test='one')) ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10009.py
Python
import mod.b reveal_type(mod.b.UserId) from mod.b import UserId reveal_type(UserId) import sib reveal_type(sib.Sib) from sib import Sib reveal_type(Sib) class Sib: pass class UserId: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10014.py
Python
DRIVE_TYPE = TypeVar('DRIVE_TYPE', bound='Driver') # This WORKS # DRIVER_STATE_TYPE = TypeVar('DRIVER_STATE_TYPE', bound='DriverState') @dataclass class DriverState(Generic[DRIVE_TYPE]): driver: DRIVE_TYPE pid: str = '' # This doesn't work DRIVER_STATE_TYPE = TypeVar('DRIVER_STATE_TYPE', bound='DriverState...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10016.py
Python
# mypy: allow-redefinition from random import random def f() -> None: x = 0 reveal_type(x) print(x) def f2() -> float: return random() x = 'x' reveal_type(x)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10023.py
Python
from typing import Any, Dict, Literal kw: Dict[Literal["a", "b"], Any] def func(a, b): pass func(**kw)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10024.py
Python
from typing import * class D(TypedDict): ... class P(Protocol): ... T = TypeVar('T', bound=P) def foo(cls: Type[T]) -> T: ... d:D = foo(D)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10026.py
Python
from typing_extensions import Final, Literal s: Final[Literal['ccc']] = 'ccc' s1: Literal[s] = s
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10027.py
Python
from typing import Any, Type def test(arg: Type[A]) -> None: return def test2() -> None: for obj in (B, C): test(obj) # ERROR IS HERE class A(Any): pass class B(A): pass class C(A): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10028.py
Python
from typing import Literal def f(x: Literal["a", "b"]): ... def g(x: str): if x == "a": ... elif x == "b": ... else: raise ValueError() f(x) # ERROR: "f" has incompatible type "str"; expected "Union[Literal['a'], Literal['b']]"
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10042.py
Python
# File bug.py try: import simplejson as json except (ImportError, SyntaxError): import json
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10054.py
Python
import sys assert sys.platform == 'win32' from sys import platform assert platform == 'win32' # good.py import sys assert sys.platform == "win32" from ctypes import WINFUNCTYPE, windll, WinError, get_last_error # bad.py from sys import platform assert platform == "win32" from ctypes import WINFUNCTYPE, windll, W...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10059.py
Python
from typing import Union def f(v: Union[int, str]) -> str: if isinstance(v, str): try: v = int(v) except ValueError: # return as is return v return str(v)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10066.py
Python
class B1: def foo(self) -> int: ... class B2: def foo(self) -> str: ... class Composite(B1, B2): # type: ignore ... class AppClass1(Composite): # <-- no error here ... class AppClass2(Composite, object): # <-- error here! ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10068.py
Python
Type = type class MyInt(int): pass x_type: Type[int] = MyInt from __future__ import annotations if sys.version_info >= (3, 9): List = list Type = type else: # Legacy generic type annotation classes # Deprecated in Python 3.9 # Remove once we no longer support Python 3.8 or lower from typ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10079.py
Python
import datetime class Bar: def __init__(self, a: int, b: str, c: datetime.datetime): pass class Baz(Bar): def __init__(self, **kwargs): super().__init__(**kwargs) Baz(b=3)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10082.py
Python
from typing import TypeVar from typing_extensions import Protocol T_co = TypeVar('T_co', covariant=True) class C(Protocol[T_co]): def __call__(self) -> T_co: ... def f(c: C) -> str: return c() def g() -> bool: return True f(g)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10083.py
Python
"{0[k-y]}".format({"k-y": "val"})
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10090.py
Python
from dataclasses import dataclass from typing import Final @dataclass class FirstClass: FIRST_CONST: Final = 3 @dataclass # mypy runs fine if this isn't a dataclass class SecondClass: SECOND_CONST: Final = FirstClass.FIRST_CONST
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10100.py
Python
from typing import TypeVar, Any T = TypeVar("T", bound=Any) def this_one_works(x: T) -> T: res = x.__new__(type(x)) return res from typing import TypeVar, Any T = TypeVar("T", bound=Any) def this_one_not_so_much(x: T) -> T: res = type(x).__new__(type(x)) return res
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10101.py
Python
from typing import Any typ_a = Any typ_b = Any def test1(x: typ_a, y: typ_b): pass from typing import Any typ_a, typ_b = Any, Any def test2(x: typ_a, y: typ_b): pass typ_a = typ_b = Any def test3(x: typ_a, y: typ_b): pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10105.py
Python
from typing import Callable, Iterable, Optional, Tuple, TypeVar SourceType = TypeVar("SourceType") TransformedType = TypeVar("TransformedType") ProcessedType = TypeVar("ProcessedType") def simple_transform_process( source: Iterable[SourceType], transform_callback: Callable[[SourceType], Optional[TransformedT...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10117.py
Python
# example.py import inspect from typing import Union, Callable, Type def some_func( error: Union[Callable[..., BaseException], Type[BaseException]] )->None: if (inspect.isfunction(error) or inspect.ismethod(error)): reveal_type(error) else: reveal_type(error)
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10120.py
Python
import typing @typing.overload def foo() -> None: ... K = typing.TypeVar('K') @typing.overload def foo(k: K) -> K: ... import typing K = typing.TypeVar('K') @typing.overload def foo() -> None: ... @typing.overload def foo(k: K) -> K: ...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10130.py
Python
from typing import Generic, TypeVar T = TypeVar("T", str, int) class GenericSuperClass(Generic[T]): def __init__(self, value: T) -> None: # mypy complains if self.value is not annotated, for some reason self.value: T = value class GenericSubClass(GenericSuperClass[T]): def __init__(self, va...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10135.py
Python
from typing import Dict, Union def fun() -> Union[Dict[str, int], Dict[int, float]]: return {}
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10140.py
Python
from dataclasses import dataclass import dataclasses from typing import Any, Dict, Generic, List, Type, TypeVar, Union from abc import ABC, abstractclassmethod from occupier.utils import EnhancedJSONEncoder T = TypeVar("T", bound="DictDataClass") @dataclass(frozen=True) class DictDataClass(Generic[T]): urn: int...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10143.py
Python
# pyright: strict from typing import Literal, Union, overload class Parent: ... class Child(Parent): ... # Test 1: Literal subtype @overload def foo1(x: Literal[3]) -> int: ... @overload def foo1(x: int) -> str: ... # Test 2: Subclass subtype @overload def foo2(x: Child) -> str: ... @overload def foo2(x: Parent) ->...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10146.py
Python
x = object() if isinstance(x, (int, str)): reveal_type(x) # Union[int, str] if isinstance(x, int): pass reveal_type(x) # object
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10151.py
Python
from typing import * class Unreachable: def member_function(self) -> None: self.path: Optional[str] = None self.other() if self.path: print(self.path) def other(self) -> None: self.path = 'hi' Unreachable().member_function()
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10152.py
Python
import typing as t T = t.TypeVar('T') V = t.TypeVar('V') def test(key: T, value: V): values: t.Dict[T, V] = {} print(values.pop(key, None)) # ok values.pop(key, value) # ok values.pop(key, None) # error: Argument 2 to "pop" of "MutableMapping" has incompatible type "None"; expected "V" values....
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10157.py
Python
@overload def func1( a: str, b: Literal[False] = ..., ) -> List[str]: ... @overload def func1( a: str, b: bool = ..., ) -> List[Union[str, int]]: ... _T = TypeVar("_T") @overload def func2( a: _T, b: Literal[False] = ..., ) -> List[_T]: ... @overload def func2( a: _T, b: bool = ..., ) -...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10160.py
Python
from typing import Any class Linear: def __init__(self, **kwargs) -> None: pass class QatLinear(Linear): def __init__(self, qconfig=None): pass def f(x: Any): if type(x) in [Linear, QatLinear]: pass
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10163.py
Python
from typing import Mapping, Optional FOO: str = "foo" def func(text: str) -> None: _ = text data: Mapping[str, Optional[str]] = {FOO: "bar"} if data[FOO] is not None: func(data[FOO]) # Line 11 if data["foo"] is not None: func(data["foo"])
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10164.py
Python
import os import typing as t T = t.TypeVar('T') R = t.TypeVar('R') class flatmap(t.Generic[T, R]): def __init__(self, func: t.Callable[[T], R]) -> None: self.func = func def __ror__(self, value: t.Optional[T]) -> t.Optional[R]: if value is not None: return self.func(value) return None # error:...
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10167.py
Python
import jwt def generate_auth() -> str: return jwt.encode({}, "secret_string", algorithm="HS384")
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10171.py
Python
from typing import Dict a: Dict[int, str] = {} b: Dict[object, str] = {object(): 'a', 'lol': 'b', **a}
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli
code_snippets/mypy/10000-10999/10173.py
Python
def return_type_a() -> TypeA: untyped = {} return untype # Disallow
Akuli/issue-downloader
0
Downloads code from GitHub issues and saves it to files
Python
Akuli