Avoid slicing sys.version_info in version conditionals

It is unnecessary, and some static analyzers don't handle it.
This commit is contained in:
Ran Benita
2024-04-27 01:11:21 +03:00
parent 93c2cdf6d6
commit 1a332802ff
7 changed files with 8 additions and 8 deletions

View File

@@ -52,7 +52,7 @@ from _pytest.pathlib import absolutepath
from _pytest.pathlib import bestrelpath
if sys.version_info[:2] < (3, 11):
if sys.version_info < (3, 11):
from exceptiongroup import BaseExceptionGroup
_TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"]
@@ -703,7 +703,7 @@ class ExceptionInfo(Generic[E]):
# Workaround for https://github.com/python/cpython/issues/98778 on
# Python <= 3.9, and some 3.10 and 3.11 patch versions.
HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ())
if sys.version_info[:2] <= (3, 11) and isinstance(exc, HTTPError):
if sys.version_info < (3, 12) and isinstance(exc, HTTPError):
notes = []
else:
raise