Debian Codegraph @

test-data/unit/check-vec.test

raw
1 [case testVecBasics]
2 from typing import Optional, Any, TypeVar
3
4 from librt.vecs import vec
5 from mypy_extensions import i64, i32, i16, u8
6
7 def f(v: vec[i64]) -> None:
8 x: i64 = v[0]
9 x = v[x]
10 v[x] = x
11
12 v = vec[i64]()
13 reveal_type(v) # N: Revealed type is "librt.vecs.vec[mypy_extensions.i64]"
14 f(v)
15 reveal_type(len(v)) # N: Revealed type is "mypy_extensions.i64"
16
17 vec_i32: vec[i32]
18 vec_i16: vec[i16]
19 vec_u8: vec[u8]
20 vec_bool: vec[bool]
21 vec_float: vec[float]
22 vec_str: vec[str]
23 vec_str_opt1: vec[str | None]
24 vec_str_opt2: vec[Optional[str]]
25 vec_nested1: vec[vec[i32]]
26 vec_nested2: vec[vec[vec[str | None]]]
27 vec_list: vec[list[int]]
28 vec_var_tuple: vec[tuple[int, ...]]
29 vec_object: vec[object]
30
31 vec_bad_int: vec[int] # E: Invalid item type for "vec"
32 vec_bad_tuple: vec[tuple[int, str]] # E: Invalid item type for "vec"
33 vec_bad_union: vec[str | ellipsis] # E: Invalid item type for "vec"
34 vec_bad_any: vec[Any] # E: Invalid item type for "vec"
35 vec_bad_two_args: vec[i32, i32] # E: Invalid item type for "vec"
36 vec_bad_optional1: vec[int | None] # E: Invalid item type for "vec"
37 vec_bad_optional2: vec[i64 | None] # E: Invalid item type for "vec"
38 vec_bad_optional3: vec[bool | None] # E: Invalid item type for "vec"
39 vec_bad_optional4: vec[float | None] # E: Invalid item type for "vec"
40
41 T = TypeVar("T")
42
43 def bad_generic_func(v: vec[T]) -> None: ... # E: Invalid item type for "vec"
44 [builtins fixtures/len.pyi]
45
46 [case testLenNoArgs]
47 len() # E: Too few arguments for "len"
48 [builtins fixtures/len.pyi]