Avoid slicing `sys.version_info` in version conditionals
It is unnecessary, and some static analyzers don't handle it.
This commit is contained in:
parent
93c2cdf6d6
commit
1a332802ff
|
@ -52,7 +52,7 @@ from _pytest.pathlib import absolutepath
|
||||||
from _pytest.pathlib import bestrelpath
|
from _pytest.pathlib import bestrelpath
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
from exceptiongroup import BaseExceptionGroup
|
from exceptiongroup import BaseExceptionGroup
|
||||||
|
|
||||||
_TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"]
|
_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
|
# Workaround for https://github.com/python/cpython/issues/98778 on
|
||||||
# Python <= 3.9, and some 3.10 and 3.11 patch versions.
|
# Python <= 3.9, and some 3.10 and 3.11 patch versions.
|
||||||
HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ())
|
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 = []
|
notes = []
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -448,7 +448,7 @@ class MyOptionParser(argparse.ArgumentParser):
|
||||||
getattr(parsed, FILE_OR_DIR).extend(unrecognized)
|
getattr(parsed, FILE_OR_DIR).extend(unrecognized)
|
||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 9): # pragma: no cover
|
if sys.version_info < (3, 9): # pragma: no cover
|
||||||
# Backport of https://github.com/python/cpython/pull/14316 so we can
|
# Backport of https://github.com/python/cpython/pull/14316 so we can
|
||||||
# disable long --argument abbreviations without breaking short flags.
|
# disable long --argument abbreviations without breaking short flags.
|
||||||
def _parse_optional(
|
def _parse_optional(
|
||||||
|
|
|
@ -69,7 +69,7 @@ from _pytest.scope import HIGH_SCOPES
|
||||||
from _pytest.scope import Scope
|
from _pytest.scope import Scope
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
from exceptiongroup import BaseExceptionGroup
|
from exceptiongroup import BaseExceptionGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ from _pytest.outcomes import Skipped
|
||||||
from _pytest.outcomes import TEST_OUTCOME
|
from _pytest.outcomes import TEST_OUTCOME
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
from exceptiongroup import BaseExceptionGroup
|
from exceptiongroup import BaseExceptionGroup
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
|
@ -28,7 +28,7 @@ import pytest
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from _pytest._code.code import _TracebackStyle
|
from _pytest._code.code import _TracebackStyle
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
from exceptiongroup import ExceptionGroup
|
from exceptiongroup import ExceptionGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ from _pytest.pytester import Pytester
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
from exceptiongroup import ExceptionGroup
|
from exceptiongroup import ExceptionGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1146,7 +1146,7 @@ def test_errors_in_xfail_skip_expressions(pytester: Pytester) -> None:
|
||||||
if pypy_version_info is not None and pypy_version_info < (6,):
|
if pypy_version_info is not None and pypy_version_info < (6,):
|
||||||
markline = markline[1:]
|
markline = markline[1:]
|
||||||
|
|
||||||
if sys.version_info[:2] >= (3, 10):
|
if sys.version_info >= (3, 10):
|
||||||
expected = [
|
expected = [
|
||||||
"*ERROR*test_nameerror*",
|
"*ERROR*test_nameerror*",
|
||||||
"*asd*",
|
"*asd*",
|
||||||
|
|
Loading…
Reference in New Issue