From 1cc1ac51838f45d819fcdbfd71df79aa851dc677 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 23 Oct 2019 14:47:56 +0300 Subject: [PATCH] Remove some type: ignores fixed in typeshed --- src/_pytest/assertion/rewrite.py | 6 +++--- src/_pytest/doctest.py | 4 +--- src/_pytest/nodes.py | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index c225eff5f..4e7db8369 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -78,7 +78,8 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder): # there's nothing to rewrite there # python3.5 - python3.6: `namespace` # python3.7+: `None` - or spec.origin in {None, "namespace"} + or spec.origin == "namespace" + or spec.origin is None # we can only rewrite source files or not isinstance(spec.loader, importlib.machinery.SourceFileLoader) # if the file doesn't exist, we can't rewrite it @@ -743,8 +744,7 @@ class AssertionRewriter(ast.NodeVisitor): from _pytest.warning_types import PytestAssertRewriteWarning import warnings - # Ignore type: typeshed bug https://github.com/python/typeshed/pull/3121 - warnings.warn_explicit( # type: ignore + warnings.warn_explicit( PytestAssertRewriteWarning( "assertion is always true, perhaps remove parentheses?" ), diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 7449a56c8..48c934e3a 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -368,9 +368,7 @@ class DoctestTextfile(pytest.Module): ) parser = doctest.DocTestParser() - # Remove ignore once this reaches mypy: - # https://github.com/python/typeshed/commit/3e4a251b2b6da6bb43137acf5abf81ecfa7ba8ee - test = parser.get_doctest(text, globs, name, filename, 0) # type: ignore + test = parser.get_doctest(text, globs, name, filename, 0) if test.examples: yield DoctestItem(test.name, self, runner, test) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index e6dee1547..71036dc7e 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -139,8 +139,7 @@ class Node: ) ) path, lineno = get_fslocation_from_item(self) - # Type ignored: https://github.com/python/typeshed/pull/3121 - warnings.warn_explicit( # type: ignore + warnings.warn_explicit( warning, category=None, filename=str(path),