From de078241d84e175a4a6827aeef34279ce569d469 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Thu, 7 Apr 2022 17:28:34 -0700 Subject: [PATCH 1/4] REF: Use import_optional_dependency in pd.test --- pandas/compat/_optional.py | 1 + pandas/util/_tester.py | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index e69bee5c647d8..43134c3ab01d5 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -17,6 +17,7 @@ "fastparquet": "0.4.0", "fsspec": "0.7.4", "html5lib": "1.1", + "hypothesis": "5.5.3", "gcsfs": "0.6.0", "jinja2": "2.11", "lxml.etree": "4.5.0", diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 6725a84aee962..774225afc5ae9 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -1,24 +1,28 @@ """ Entrypoint for testing from the top-level namespace. """ +from __future__ import annotations import os import sys +from pandas.compat._optional import import_optional_dependency + PKG = os.path.dirname(os.path.dirname(__file__)) -def test(extra_args=None): +def test(extra_args: list[str] | None = None): """ Run the pandas test suite using pytest. + + By default, runs with the marks --skip-slow, --skip-network, --skip-db + + Parameters + ---------- + extra_args : list[str], default None + Extra marks to run the tests. """ - try: - import pytest - except ImportError as err: - raise ImportError("Need pytest>=5.0.1 to run tests") from err - try: - import hypothesis # noqa:F401 - except ImportError as err: - raise ImportError("Need hypothesis>=3.58 to run tests") from err + pytest = import_optional_dependency("pytest") + import_optional_dependency("hypothesis") cmd = ["--skip-slow", "--skip-network", "--skip-db"] if extra_args: if not isinstance(extra_args, list): From 31c77bf3b424b4e792ef6cb67b2eaff5872530c9 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Fri, 8 Apr 2022 21:20:05 -0700 Subject: [PATCH 2/4] Format --- pandas/util/_tester.py | 1 + scripts/validate_min_versions_in_sync.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 774225afc5ae9..1b018a6a1ba34 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -2,6 +2,7 @@ Entrypoint for testing from the top-level namespace. """ from __future__ import annotations + import os import sys diff --git a/scripts/validate_min_versions_in_sync.py b/scripts/validate_min_versions_in_sync.py index 4dbf6a4cdcef8..e617c8da4536a 100755 --- a/scripts/validate_min_versions_in_sync.py +++ b/scripts/validate_min_versions_in_sync.py @@ -14,6 +14,7 @@ from __future__ import annotations import pathlib +import re import sys DOC_PATH = pathlib.Path("doc/source/getting_started/install.rst").resolve() @@ -53,7 +54,7 @@ def get_versions_from_ci(content: list[str]) -> tuple[dict[str, str], dict[str, elif "# optional dependencies" in line: seen_optional = True elif seen_required and line.strip(): - package, version = line.strip().split("=") + package, version = re.split(r">?=", line.strip()) package = package[2:] if not seen_optional: required_deps[package] = version From f3effd10fe7945fb1231c932dea2d6cf8eef862d Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 9 Apr 2022 10:35:03 -0700 Subject: [PATCH 3/4] Move hypothesis to optional dependency --- ci/deps/actions-310.yaml | 2 +- ci/deps/actions-38-downstream_compat.yaml | 2 +- ci/deps/actions-38-minimum_versions.yaml | 2 +- ci/deps/actions-38.yaml | 2 +- ci/deps/actions-39.yaml | 2 +- ci/deps/circle-38-arm64.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/deps/actions-310.yaml b/ci/deps/actions-310.yaml index dac1219245e84..369d27b8c97b9 100644 --- a/ci/deps/actions-310.yaml +++ b/ci/deps/actions-310.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/actions-38-downstream_compat.yaml b/ci/deps/actions-38-downstream_compat.yaml index 629d7b501692d..946e86bf62674 100644 --- a/ci/deps/actions-38-downstream_compat.yaml +++ b/ci/deps/actions-38-downstream_compat.yaml @@ -10,7 +10,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -28,6 +27,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/actions-38-minimum_versions.yaml b/ci/deps/actions-38-minimum_versions.yaml index f3a967f67cbc3..99f8b89d1d562 100644 --- a/ci/deps/actions-38-minimum_versions.yaml +++ b/ci/deps/actions-38-minimum_versions.yaml @@ -11,7 +11,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -29,6 +28,7 @@ dependencies: - fastparquet=0.4.0 - fsspec=0.7.4 - html5lib=1.1 + - hypothesis=5.5.3 - gcsfs=0.6.0 - jinja2=2.11 - lxml=4.5.0 diff --git a/ci/deps/actions-38.yaml b/ci/deps/actions-38.yaml index 79cd831051c2f..2b07d5f9e89a7 100644 --- a/ci/deps/actions-38.yaml +++ b/ci/deps/actions-38.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/actions-39.yaml b/ci/deps/actions-39.yaml index 1c681104f3196..de726e105a8f8 100644 --- a/ci/deps/actions-39.yaml +++ b/ci/deps/actions-39.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/circle-38-arm64.yaml b/ci/deps/circle-38-arm64.yaml index 66fedccc5eca7..0f57dc8058086 100644 --- a/ci/deps/circle-38-arm64.yaml +++ b/ci/deps/circle-38-arm64.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml From 87a72bf73892c8a43d39732843a7d4740164a668 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 9 Apr 2022 10:37:03 -0700 Subject: [PATCH 4/4] Revert sync script --- scripts/validate_min_versions_in_sync.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/validate_min_versions_in_sync.py b/scripts/validate_min_versions_in_sync.py index e617c8da4536a..4dbf6a4cdcef8 100755 --- a/scripts/validate_min_versions_in_sync.py +++ b/scripts/validate_min_versions_in_sync.py @@ -14,7 +14,6 @@ from __future__ import annotations import pathlib -import re import sys DOC_PATH = pathlib.Path("doc/source/getting_started/install.rst").resolve() @@ -54,7 +53,7 @@ def get_versions_from_ci(content: list[str]) -> tuple[dict[str, str], dict[str, elif "# optional dependencies" in line: seen_optional = True elif seen_required and line.strip(): - package, version = re.split(r">?=", line.strip()) + package, version = line.strip().split("=") package = package[2:] if not seen_optional: required_deps[package] = version