[7.4.x] Fixes for typed pluggy (#11355) · pytest-dev/pytest@7a5f2fe (original) (raw)

`@@ -444,10 +444,10 @@ def parse_hookimpl_opts(self, plugin: _PluggyPlugin, name: str):

`

444

444

`# so we avoid accessing possibly non-readable attributes

`

445

445

`# (see issue #1073).

`

446

446

`if not name.startswith("pytest_"):

`

447

``

`-

return

`

``

447

`+

return None

`

448

448

`# Ignore names which can not be hooks.

`

449

449

`if name == "pytest_plugins":

`

450

``

`-

return

`

``

450

`+

return None

`

451

451

``

452

452

`opts = super().parse_hookimpl_opts(plugin, name)

`

453

453

`if opts is not None:

`

`@@ -456,9 +456,9 @@ def parse_hookimpl_opts(self, plugin: _PluggyPlugin, name: str):

`

456

456

`method = getattr(plugin, name)

`

457

457

`# Consider only actual functions for hooks (#3775).

`

458

458

`if not inspect.isroutine(method):

`

459

``

`-

return

`

``

459

`+

return None

`

460

460

`` # Collect unmarked hooks as long as they have the `pytest_' prefix.

``

461

``

`-

return _get_legacy_hook_marks(

`

``

461

`+

return _get_legacy_hook_marks( # type: ignore[return-value]

`

462

462

`method, "impl", ("tryfirst", "trylast", "optionalhook", "hookwrapper")

`

463

463

` )

`

464

464

``

`@@ -467,7 +467,7 @@ def parse_hookspec_opts(self, module_or_class, name: str):

`

467

467

`if opts is None:

`

468

468

`method = getattr(module_or_class, name)

`

469

469

`if name.startswith("pytest_"):

`

470

``

`-

opts = _get_legacy_hook_marks(

`

``

470

`+

opts = _get_legacy_hook_marks( # type: ignore[assignment]

`

471

471

`method,

`

472

472

`"spec",

`

473

473

` ("firstresult", "historic"),

`

`@@ -1065,9 +1065,10 @@ def _ensure_unconfigure(self) -> None:

`

1065

1065

`fin()

`

1066

1066

``

1067

1067

`def get_terminal_writer(self) -> TerminalWriter:

`

1068

``

`-

terminalreporter: TerminalReporter = self.pluginmanager.get_plugin(

`

``

1068

`+

terminalreporter: Optional[TerminalReporter] = self.pluginmanager.get_plugin(

`

1069

1069

`"terminalreporter"

`

1070

1070

` )

`

``

1071

`+

assert terminalreporter is not None

`

1071

1072

`return terminalreporter._tw

`

1072

1073

``

1073

1074

`def pytest_cmdline_parse(

`