Skip to content

Commit 6ce2e97

Browse files
Remove code that is impossible to reach on python 3.9+
1 parent a477986 commit 6ce2e97

File tree

2 files changed

+0
-44
lines changed

2 files changed

+0
-44
lines changed

src/_pytest/config/argparsing.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import argparse
55
from collections.abc import Mapping
66
from collections.abc import Sequence
7-
from gettext import gettext
87
import os
9-
import sys
108
from typing import Any
119
from typing import Callable
1210
from typing import cast
@@ -446,44 +444,6 @@ def parse_args( # type: ignore
446444
getattr(parsed, FILE_OR_DIR).extend(unrecognized)
447445
return parsed
448446

449-
if sys.version_info < (3, 9): # pragma: no cover
450-
# Backport of https://github.com/python/cpython/pull/14316 so we can
451-
# disable long --argument abbreviations without breaking short flags.
452-
def _parse_optional(
453-
self, arg_string: str
454-
) -> tuple[argparse.Action | None, str, str | None] | None:
455-
if not arg_string:
456-
return None
457-
if arg_string[0] not in self.prefix_chars:
458-
return None
459-
if arg_string in self._option_string_actions:
460-
action = self._option_string_actions[arg_string]
461-
return action, arg_string, None
462-
if len(arg_string) == 1:
463-
return None
464-
if "=" in arg_string:
465-
option_string, explicit_arg = arg_string.split("=", 1)
466-
if option_string in self._option_string_actions:
467-
action = self._option_string_actions[option_string]
468-
return action, option_string, explicit_arg
469-
if self.allow_abbrev or not arg_string.startswith("--"):
470-
option_tuples = self._get_option_tuples(arg_string)
471-
if len(option_tuples) > 1:
472-
msg = gettext(
473-
"ambiguous option: %(option)s could match %(matches)s"
474-
)
475-
options = ", ".join(option for _, option, _ in option_tuples)
476-
self.error(msg % {"option": arg_string, "matches": options})
477-
elif len(option_tuples) == 1:
478-
(option_tuple,) = option_tuples
479-
return option_tuple
480-
if self._negative_number_matcher.match(arg_string):
481-
if not self._has_negative_number_optionals:
482-
return None
483-
if " " in arg_string:
484-
return None
485-
return None, arg_string, None
486-
487447

488448
class DropShorterLongHelpFormatter(argparse.HelpFormatter):
489449
"""Shorten help for long options that differ only in extra hyphens.

testing/test_assertrewrite.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,10 +1018,6 @@ def test_zipfile(self, pytester: Pytester) -> None:
10181018
)
10191019
assert pytester.runpytest().ret == ExitCode.NO_TESTS_COLLECTED
10201020

1021-
@pytest.mark.skipif(
1022-
sys.version_info < (3, 9),
1023-
reason="importlib.resources.files was introduced in 3.9",
1024-
)
10251021
def test_load_resource_via_files_with_rewrite(self, pytester: Pytester) -> None:
10261022
example = pytester.path.joinpath("demo") / "example"
10271023
init = pytester.path.joinpath("demo") / "__init__.py"

0 commit comments

Comments
 (0)