Skip to content

Commit

Permalink
Rename # pants: ignore to # pants: no-infer-dep (#14225)
Browse files Browse the repository at this point in the history
  • Loading branch information
thejcannon committed Jan 21, 2022
1 parent 1c19c41 commit c184d0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Expand Up @@ -88,19 +88,19 @@ def test_normal_imports(rule_runner: RuleRunner) -> None:
import demo
from project.demo import Demo
from project.demo import OriginalName as Renamed
import pragma_ignored # pants: ignore
from also_pragma_ignored import doesnt_matter # pants: ignore
import pragma_ignored # pants: no-infer-dep
from also_pragma_ignored import doesnt_matter # pants: no-infer-dep
from multiline_import1 import (
not_ignored1,
ignored1 as alias1, # pants: ignore
ignored1 as alias1, # pants: no-infer-dep
ignored2 as \\
alias2, # pants: ignore
ignored3 as # pants: ignore
alias2, # pants: no-infer-dep
ignored3 as # pants: no-infer-dep
alias3,
ignored4 as alias4, ignored4, # pants: ignore
ignored4 as alias4, ignored4, # pants: no-infer-dep
not_ignored2,
)
from multiline_import2 import (ignored1, # pants: ignore
from multiline_import2 import (ignored1, # pants: no-infer-dep
not_ignored)
if TYPE_CHECKING:
Expand Down Expand Up @@ -131,16 +131,16 @@ def test_dunder_import_call(rule_runner: RuleRunner) -> None:
content = dedent(
"""\
__import__("pkg_resources")
__import__("dunder_import_ignored") # pants: ignore
__import__( # pants: ignore
__import__("dunder_import_ignored") # pants: no-infer-dep
__import__( # pants: no-infer-dep
"not_ignored_but_looks_like_it_could_be"
)
__import__(
"ignored" # pants: ignore
"ignored" # pants: no-infer-dep
)
__import__(
"also_not_ignored_but_looks_like_it_could_be"
) # pants: ignore
) # pants: no-infer-dep
"""
)
assert_imports_parsed(
Expand Down
Expand Up @@ -50,10 +50,10 @@ def add_strong_import(self, name, lineno):

@staticmethod
def _is_pragma_ignored(line):
return "# pants: ignore" in line
return "# pants: no-infer-dep" in line

def _visit_import_stmt(self, node, import_prefix):
# N.B. We only add imports whose line doesn't contain "# pants: ignore"
# N.B. We only add imports whose line doesn't contain "# pants: no-infer-dep"
# However, `ast` doesn't expose the exact lines each specific import is on,
# so we are forced to tokenize the import statement to tease out which imported
# name is on which line so we can check for the ignore pragma.
Expand Down

0 comments on commit c184d0a

Please sign in to comment.