diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index e6f4c2dea..b3aff258a 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -392,8 +392,7 @@ class MyOptionParser(argparse.ArgumentParser): prog: Optional[str] = None, ) -> None: self._parser = parser - argparse.ArgumentParser.__init__( - self, + super().__init__( prog=prog, usage=parser._usage, add_help=False, @@ -486,7 +485,7 @@ class DropShorterLongHelpFormatter(argparse.HelpFormatter): super().__init__(*args, **kwargs) def _format_action_invocation(self, action: argparse.Action) -> str: - orgstr = argparse.HelpFormatter._format_action_invocation(self, action) + orgstr = super()._format_action_invocation(action) if orgstr and orgstr[0] != "-": # only optional arguments return orgstr res: Optional[str] = getattr(action, "_formatted_action_invocation", None) diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index f799f5f9c..fdf6f59fb 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -190,8 +190,7 @@ def _init_runner_class() -> Type["doctest.DocTestRunner"]: optionflags: int = 0, continue_on_failure: bool = True, ) -> None: - doctest.DebugRunner.__init__( - self, checker=checker, verbose=verbose, optionflags=optionflags + super().__init__(checker=checker, verbose=verbose, optionflags=optionflags ) self.continue_on_failure = continue_on_failure @@ -513,8 +512,7 @@ class DoctestModule(pytest.Module): if isinstance(obj, property): obj = getattr(obj, "fget", obj) # Type ignored because this is a private function. - return doctest.DocTestFinder._find_lineno( # type: ignore - self, + return super()._find_lineno( obj, source_lines, ) @@ -527,8 +525,7 @@ class DoctestModule(pytest.Module): with _patch_unwrap_mock_aware(): # Type ignored because this is a private function. - doctest.DocTestFinder._find( # type: ignore - self, tests, obj, name, module, source_lines, globs, seen + super()._find(tests, obj, name, module, source_lines, globs, seen ) if self.path.name == "conftest.py": @@ -613,7 +610,7 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]: ) def check_output(self, want: str, got: str, optionflags: int) -> bool: - if doctest.OutputChecker.check_output(self, want, got, optionflags): + if super().check_output(want, got, optionflags): return True allow_unicode = optionflags & _get_allow_unicode_flag() @@ -637,7 +634,7 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]: if allow_number: got = self._remove_unwanted_precision(want, got) - return doctest.OutputChecker.check_output(self, want, got, optionflags) + return super().check_output(want, got, optionflags) def _remove_unwanted_precision(self, want: str, got: str) -> str: wants = list(self._number_re.finditer(want)) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 9580d39f9..7f73b8a46 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -784,7 +784,7 @@ class _LiveLoggingStreamHandler(logging.StreamHandler): terminal_reporter: TerminalReporter, capture_manager: Optional[CaptureManager], ) -> None: - logging.StreamHandler.__init__(self, stream=terminal_reporter) # type: ignore[arg-type] + super().__init__(stream=terminal_reporter) # type: ignore[arg-type] self.capture_manager = capture_manager self.reset() self.set_when(None) diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index 2addf5572..5dab12174 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -33,7 +33,7 @@ class OutcomeException(BaseException): "Perhaps you meant to use a mark?" ) raise TypeError(error_msg.format(type(self).__name__, type(msg).__name__)) - BaseException.__init__(self, msg) + super().__init__(msg) self.msg = msg self.pytrace = pytrace @@ -61,7 +61,7 @@ class Skipped(OutcomeException): *, _use_item_location: bool = False, ) -> None: - OutcomeException.__init__(self, msg=msg, pytrace=pytrace) + super().__init__(msg=msg, pytrace=pytrace) self.allow_module_level = allow_module_level # If true, the skip location is reported as the item's location, # instead of the place that raises the exception/calls skip(). diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 8332bbe0a..735b016c5 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -221,7 +221,7 @@ class ApproxNumpy(ApproxBase): if not np.isscalar(actual) and actual.shape != self.expected.shape: return False - return ApproxBase.__eq__(self, actual) + return super().__eq__(actual) def _yield_comparisons(self, actual): import numpy as np @@ -292,7 +292,7 @@ class ApproxMapping(ApproxBase): except AttributeError: return False - return ApproxBase.__eq__(self, actual) + return super().__eq__(actual) def _yield_comparisons(self, actual): for k in self.expected.keys(): @@ -365,7 +365,7 @@ class ApproxSequencelike(ApproxBase): return False except TypeError: return False - return ApproxBase.__eq__(self, actual) + return super().__eq__(actual) def _yield_comparisons(self, actual): return zip(actual, self.expected) diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 26ea22f33..108095bfc 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -322,7 +322,7 @@ class TestCaseFunction(Function): def _prunetraceback( self, excinfo: _pytest._code.ExceptionInfo[BaseException] ) -> None: - Function._prunetraceback(self, excinfo) + super()._prunetraceback(excinfo) traceback = excinfo.traceback.filter( lambda x: not x.frame.f_globals.get("__unittest") )