Skip to content

TYP: Type annotaion for test decorators #31454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def test_foo():

For more information, refer to the ``pytest`` documentation on ``skipif``.
"""

from distutils.version import LooseVersion
from functools import wraps
import locale
from typing import Callable, Optional

from _pytest.mark.structures import MarkDecorator
import numpy as np
import pytest

Expand Down Expand Up @@ -120,7 +122,7 @@ def _skip_if_no_scipy() -> bool:
)


def skip_if_installed(package: str) -> Callable:
def skip_if_installed(package: str) -> MarkDecorator:
"""
Skip a test if a package is installed.

Expand All @@ -134,7 +136,7 @@ def skip_if_installed(package: str) -> Callable:
)


def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable:
def skip_if_no(package: str, min_version: Optional[str] = None) -> MarkDecorator:
"""
Generic function to help skip tests when required packages are not
present on the testing system.
Expand Down Expand Up @@ -198,7 +200,7 @@ def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable:

def skip_if_np_lt(
ver_str: str, reason: Optional[str] = None, *args, **kwds
) -> Callable:
) -> MarkDecorator:
if reason is None:
reason = f"NumPy {ver_str} or greater required"
return pytest.mark.skipif(
Expand Down Expand Up @@ -254,7 +256,7 @@ def new_func(*args, **kwargs):
return new_func


def async_mark():
def async_mark() -> MarkDecorator:
try:
import_optional_dependency("pytest_asyncio")
async_mark = pytest.mark.asyncio
Expand Down