From f84ffd974719dd2500968fe44e5d63c9562812e8 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 8 Jun 2020 21:21:58 +0300 Subject: [PATCH] Remove unused type: ignores Not needed since update from mypy 0.770 -> 0.780. --- src/_pytest/cacheprovider.py | 3 +-- src/_pytest/capture.py | 8 +++----- src/_pytest/config/__init__.py | 4 +--- src/_pytest/mark/structures.py | 4 +--- testing/test_assertrewrite.py | 2 +- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 9baee1d4e..305a122e9 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -464,8 +464,7 @@ def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]: @pytest.hookimpl(tryfirst=True) def pytest_configure(config: Config) -> None: - # Type ignored: pending mechanism to store typed objects scoped to config. - config.cache = Cache.for_config(config) # type: ignore # noqa: F821 + config.cache = Cache.for_config(config) config.pluginmanager.register(LFPlugin(config), "lfplugin") config.pluginmanager.register(NFPlugin(config), "nfplugin") diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 041041284..6009e1f67 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -519,11 +519,10 @@ class MultiCapture: def pop_outerr_to_orig(self): """ pop current snapshot out/err capture and flush to orig streams. """ out, err = self.readouterr() - # TODO: Fix type ignores. if out: - self.out.writeorg(out) # type: ignore[union-attr] # noqa: F821 + self.out.writeorg(out) if err: - self.err.writeorg(err) # type: ignore[union-attr] # noqa: F821 + self.err.writeorg(err) return out, err def suspend_capturing(self, in_: bool = False) -> None: @@ -543,8 +542,7 @@ class MultiCapture: if self.err: self.err.resume() if self._in_suspended: - # TODO: Fix type ignore. - self.in_.resume() # type: ignore[union-attr] # noqa: F821 + self.in_.resume() self._in_suspended = False def stop_capturing(self) -> None: diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index c94ea2a93..daccdc6a1 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -988,9 +988,7 @@ class Config: package_files = ( str(file) for dist in importlib_metadata.distributions() - # Type ignored due to missing stub: - # https://github.com/python/typeshed/pull/3795 - if any(ep.group == "pytest11" for ep in dist.entry_points) # type: ignore + if any(ep.group == "pytest11" for ep in dist.entry_points) for file in dist.files or [] ) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 7abff9b7b..3d512816c 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -66,9 +66,7 @@ def get_empty_parameterset_mark( fs, lineno, ) - # Type ignored because MarkDecorator.__call__() is a bit tough to - # annotate ATM. - return mark(reason=reason) # type: ignore[no-any-return] # noqa: F723 + return mark(reason=reason) class ParameterSet( diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 3813993be..38893deb9 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1258,7 +1258,7 @@ class TestEarlyRewriteBailout: def spy_find_spec(name, path): self.find_spec_calls.append(name) - return importlib.machinery.PathFinder.find_spec(name, path) # type: ignore + return importlib.machinery.PathFinder.find_spec(name, path) hook = AssertionRewritingHook(pytestconfig) # use default patterns, otherwise we inherit pytest's testing config