Skip to content

Commit c24c298

Browse files
Add generated Python typing stubs to allow for better mypy checks
Without these generated API descriptions, we'd have to disable all checks which use these APIs because we'd have to typing info for them. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
1 parent 99b845a commit c24c298

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-0
lines changed

stubs/parameterized/__init__.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .parameterized import param as param, parameterized as parameterized, parameterized_class as parameterized_class

stubs/parameterized/parameterized.pyi

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
from _typeshed import Incomplete
2+
from collections import OrderedDict as MaybeOrderedDict
3+
from typing import NamedTuple
4+
5+
# MaybeOrderedDict = dict
6+
7+
class SkipTest(Exception): ...
8+
9+
PY3: Incomplete
10+
PY2: Incomplete
11+
PYTEST4: Incomplete
12+
13+
class InstanceType: ...
14+
15+
lzip: Incomplete
16+
text_type = str
17+
string_types: Incomplete
18+
bytes_type = bytes
19+
20+
def make_method(func, instance, type): ...
21+
def to_text(x): ...
22+
23+
class CompatArgSpec(NamedTuple):
24+
args: Incomplete
25+
varargs: Incomplete
26+
keywords: Incomplete
27+
defaults: Incomplete
28+
29+
def getargspec(func): ...
30+
def skip_on_empty_helper(*a, **kw) -> None: ...
31+
def reapply_patches_if_need(func): ...
32+
def delete_patches_if_need(func) -> None: ...
33+
34+
class _param(NamedTuple):
35+
args: Incomplete
36+
kwargs: Incomplete
37+
38+
class param(_param):
39+
def __new__(cls, *args, **kwargs): ...
40+
@classmethod
41+
def explicit(cls, args: Incomplete | None = ..., kwargs: Incomplete | None = ...): ...
42+
@classmethod
43+
def from_decorator(cls, args): ...
44+
45+
class QuietOrderedDict(MaybeOrderedDict): ... # type: ignore
46+
47+
def parameterized_argument_value_pairs(func, p): ...
48+
def short_repr(x, n: int = ...): ...
49+
def default_doc_func(func, num, p): ...
50+
def default_name_func(func, num, p): ...
51+
def set_test_runner(name) -> None: ...
52+
def detect_runner(): ...
53+
54+
class parameterized:
55+
get_input: Incomplete
56+
doc_func: Incomplete
57+
skip_on_empty: Incomplete
58+
def __init__(self, input, doc_func: Incomplete | None = ..., skip_on_empty: bool = ...) -> None: ...
59+
def __call__(self, test_func): ...
60+
def param_as_nose_tuple(self, test_self, func, num, p): ...
61+
def assert_not_in_testcase_subclass(self) -> None: ...
62+
@classmethod
63+
def input_as_callable(cls, input): ...
64+
@classmethod
65+
def check_input_values(cls, input_values): ...
66+
@classmethod
67+
def expand(cls, input, name_func: Incomplete | None = ..., doc_func: Incomplete | None = ..., skip_on_empty: bool = ..., **legacy): ...
68+
@classmethod
69+
def param_as_standalone_func(cls, p, func, name): ...
70+
@classmethod
71+
def to_safe_name(cls, s): ...
72+
73+
def parameterized_class(attrs, input_values: Incomplete | None = ..., class_name_func: Incomplete | None = ..., classname_func: Incomplete | None = ...): ...
74+
def unwrap_mock_patch_func(f): ...
75+
def get_class_name_suffix(params_dict): ...
76+
def default_class_name_func(cls, num, params_dict): ...

stubs/parameterized/test.pyi

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
from .parameterized import PY2 as PY2, PY3 as PY3, PYTEST4 as PYTEST4, SkipTest as SkipTest, detect_runner as detect_runner, param as param, parameterized as parameterized, parameterized_argument_value_pairs as parameterized_argument_value_pairs, parameterized_class as parameterized_class, short_repr as short_repr
2+
from _typeshed import Incomplete
3+
from unittest import TestCase
4+
5+
def assert_contains(haystack, needle) -> None: ...
6+
7+
runner: Incomplete
8+
UNITTEST: Incomplete
9+
NOSE2: Incomplete
10+
PYTEST: Incomplete
11+
SKIP_FLAGS: Incomplete
12+
missing_tests: Incomplete
13+
14+
def expect(skip, tests: Incomplete | None = ...) -> None: ...
15+
16+
test_params: Incomplete
17+
18+
def test_naked_function(foo, bar: Incomplete | None = ...) -> None: ...
19+
20+
class TestParameterized:
21+
def test_instance_method(self, foo, bar: Incomplete | None = ...) -> None: ...
22+
23+
class TestSetupTeardown:
24+
stack: Incomplete
25+
actual_order: str
26+
def setUp(self) -> None: ...
27+
def tearDown(self) -> None: ...
28+
def test_setup(self, count, *a) -> None: ...
29+
30+
def custom_naming_func(custom_tag, kw_name): ...
31+
32+
class TestParameterizedExpandWithMockPatchForClass(TestCase):
33+
def test_one_function_patch_decorator(self, foo, mock_umask, mock_getpid) -> None: ...
34+
def test_multiple_function_patch_decorator(self, foo, bar, mock_umask, mock_fdopen, mock_getpid) -> None: ...
35+
36+
class TestParameterizedExpandWithNoExpand:
37+
def test_patch_class_no_expand(self, foo, bar, mock_umask, mock_getpid) -> None: ...
38+
39+
class TestParameterizedExpandWithNoMockPatchForClass(TestCase):
40+
def test_one_function_patch_decorator(self, foo, mock_umask) -> None: ...
41+
def test_multiple_function_patch_decorator(self, foo, bar, mock_umask, mock_fdopen) -> None: ...
42+
43+
class TestParameterizedExpandWithNoMockPatchForClassNoExpand:
44+
def test_patch_no_expand(self, foo, bar, mock_umask) -> None: ...
45+
46+
def test_mock_patch_standalone_function(foo, mock_umask) -> None: ...
47+
48+
class TestParamerizedOnTestCase(TestCase):
49+
def test_on_TestCase(self, foo, bar: Incomplete | None = ...) -> None: ...
50+
def test_on_TestCase2(self, foo, bar: Incomplete | None = ...) -> None: ...
51+
52+
class TestParameterizedExpandDocstring(TestCase):
53+
def test_custom_doc_func(self, foo, bar: Incomplete | None = ...) -> None: ...
54+
def test_single_line_docstring(self, foo) -> None: ...
55+
def test_empty_docstring(self, foo) -> None: ...
56+
def test_multiline_documentation(self, foo) -> None: ...
57+
def test_unicode_docstring(self, foo) -> None: ...
58+
def test_default_values_get_correct_value(self, foo, bar: int = ...) -> None: ...
59+
def test_with_leading_newline(self, foo, bar: int = ...) -> None: ...
60+
61+
def test_warns_when_using_parameterized_with_TestCase() -> None: ...
62+
def test_helpful_error_on_invalid_parameters() -> None: ...
63+
def test_helpful_error_on_empty_iterable_input() -> None: ...
64+
def test_skip_test_on_empty_iterable() -> None: ...
65+
def test_helpful_error_on_empty_iterable_input_expand() -> None: ...
66+
def test_wrapped_iterable_input(foo) -> None: ...
67+
def test_helpful_error_on_non_iterable_input(): ...
68+
def tearDownModule() -> None: ...
69+
def test_old_style_classes() -> None: ...
70+
71+
class TestOldStyleClass:
72+
def test_old_style_classes(self, param) -> None: ...
73+
74+
def test_parameterized_argument_value_pairs(func_params, p, expected) -> None: ...
75+
def test_short_repr(input, expected, n: int = ...) -> None: ...
76+
def test_with_docstring(input) -> None: ...
77+
78+
cases_over_10: Incomplete
79+
80+
def test_cases_over_10(input, expected) -> None: ...
81+
82+
class TestParameterizedClass(TestCase):
83+
def test_method_a(self) -> None: ...
84+
def test_method_b(self) -> None: ...
85+
def testCamelCaseMethodC(self) -> None: ...
86+
87+
class TestNamedParameterizedClass(TestCase):
88+
def test_method(self) -> None: ...
89+
90+
class TestParameterizedClassDict(TestCase):
91+
foo: int
92+
bar: str
93+
def setUp(self) -> None: ...
94+
def tearDown(self) -> None: ...
95+
def test_method(self) -> None: ...
96+
97+
class TestUnicodeDocstring:
98+
def test_with_docstring(self, param) -> None: ...
99+
100+
def test_missing_argument_error() -> None: ...

0 commit comments

Comments
 (0)