From e9fb50dfb23abdf2b231ab374388cde9efc5ffaa Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 26 Jun 2024 12:41:36 -0400 Subject: [PATCH] Exclude coverage for older Python version checks --- .coveragerc | 3 +++ setuptools/_path.py | 6 +++--- setuptools/compat/py310.py | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.coveragerc b/.coveragerc index 5b7fdefd2a..50d4bad837 100644 --- a/.coveragerc +++ b/.coveragerc @@ -20,3 +20,6 @@ exclude_also = # jaraco/skeleton#97 @overload if TYPE_CHECKING: + # Coverage is only run on the latest Python version + # these will never be considered covered and we aim for 100% coverage + if sys\.version_info < diff --git a/setuptools/_path.py b/setuptools/_path.py index fb8ef0e198..100dde5719 100644 --- a/setuptools/_path.py +++ b/setuptools/_path.py @@ -2,10 +2,10 @@ import sys from typing import Union -if sys.version_info >= (3, 9): - StrPath = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath -else: +if sys.version_info < (3, 9): StrPath = Union[str, os.PathLike] +else: + StrPath = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath def ensure_directory(path): diff --git a/setuptools/compat/py310.py b/setuptools/compat/py310.py index f7d53d6de9..b775961570 100644 --- a/setuptools/compat/py310.py +++ b/setuptools/compat/py310.py @@ -4,7 +4,7 @@ __all__ = ['tomllib'] -if sys.version_info >= (3, 11): - import tomllib -else: # pragma: no cover +if sys.version_info < (3, 11): from setuptools.extern import tomli as tomllib +else: + import tomllib