Skip to content

Commit

Permalink
Fix address parse bug in update-build-files --fix-python-macros. (#…
Browse files Browse the repository at this point in the history
…14485)

This issue was introduced by #14346 

[ci skip-rust]
  • Loading branch information
kaos authored Feb 17, 2022
1 parent bb0c2a6 commit 30f9b53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/macros/deprecation_fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pants.backend.python.lint.pylint.subsystem import Pylint
from pants.backend.python.target_types import PythonRequirementsFileTarget, PythonRequirementTarget
from pants.backend.python.typecheck.mypy.subsystem import MyPy
from pants.build_graph.address import InvalidAddress
from pants.build_graph.address import AddressParseException, InvalidAddress
from pants.core.goals.update_build_files import (
DeprecationFixerRequest,
RewrittenBuildFile,
Expand Down Expand Up @@ -170,7 +170,7 @@ def maybe_address(val: str, renames: MacroRenames, *, relative_to: str | None) -
# we know that none of the generated targets will be file addresses. That is, we can
# ignore file addresses.
addr = AddressInput.parse(val, relative_to=relative_to).dir_to_address()
except InvalidAddress:
except (AddressParseException, InvalidAddress):
return None

return addr if addr in renames.generated else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
OptionsChecker,
OptionsCheckerRequest,
UpdatePythonMacrosRequest,
maybe_address,
)
from pants.backend.python.macros.pipenv_requirements_caof import PipenvRequirementsCAOF
from pants.backend.python.macros.poetry_requirements_caof import PoetryRequirementsCAOF
Expand Down Expand Up @@ -275,3 +276,10 @@ def test_check_options(rule_runner: RuleRunner, caplog) -> None:
assert "pylint" not in caplog.text
assert "mypy" not in caplog.text
assert "python-thrift" not in caplog.text


def test_invalid_address() -> None:
assert (
maybe_address("no/address@here:123", MacroRenames((), FrozenDict()), relative_to=None)
is None
)

0 comments on commit 30f9b53

Please sign in to comment.