Skip to content

Commit 8b0a99d

Browse files
authored
TYP: annotate testing decorators with pytest.MarkDecorator (#53794)
TYP: type pytest.MarkDecorator
1 parent 2742623 commit 8b0a99d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pandas/util/_test_decorators.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,27 @@ def _skip_if_no_scipy() -> bool:
114114
)
115115

116116

117-
# TODO(pytest#7469): return type, _pytest.mark.structures.MarkDecorator is not public
118-
# https://github.com/pytest-dev/pytest/issues/7469
119-
def skip_if_installed(package: str):
117+
def skip_if_installed(package: str) -> pytest.MarkDecorator:
120118
"""
121119
Skip a test if a package is installed.
122120
123121
Parameters
124122
----------
125123
package : str
126124
The name of the package.
125+
126+
Returns
127+
-------
128+
pytest.MarkDecorator
129+
a pytest.mark.skipif to use as either a test decorator or a
130+
parametrization mark.
127131
"""
128132
return pytest.mark.skipif(
129133
safe_import(package), reason=f"Skipping because {package} is installed."
130134
)
131135

132136

133-
# TODO(pytest#7469): return type, _pytest.mark.structures.MarkDecorator is not public
134-
# https://github.com/pytest-dev/pytest/issues/7469
135-
def skip_if_no(package: str, min_version: str | None = None):
137+
def skip_if_no(package: str, min_version: str | None = None) -> pytest.MarkDecorator:
136138
"""
137139
Generic function to help skip tests when required packages are not
138140
present on the testing system.
@@ -158,7 +160,7 @@ def skip_if_no(package: str, min_version: str | None = None):
158160
159161
Returns
160162
-------
161-
_pytest.mark.structures.MarkDecorator
163+
pytest.MarkDecorator
162164
a pytest.mark.skipif to use as either a test decorator or a
163165
parametrization mark.
164166
"""
@@ -189,9 +191,9 @@ def skip_if_no(package: str, min_version: str | None = None):
189191
)
190192

191193

192-
# TODO(pytest#7469): return type, _pytest.mark.structures.MarkDecorator is not public
193-
# https://github.com/pytest-dev/pytest/issues/7469
194-
def skip_if_np_lt(ver_str: str, *args, reason: str | None = None):
194+
def skip_if_np_lt(
195+
ver_str: str, *args, reason: str | None = None
196+
) -> pytest.MarkDecorator:
195197
if reason is None:
196198
reason = f"NumPy {ver_str} or greater required"
197199
return pytest.mark.skipif(

0 commit comments

Comments
 (0)