Skip to content

Commit

Permalink
Error on unowned internal Python dependencies (pantsbuild#15331)
Browse files Browse the repository at this point in the history
The dogfooding is good, especially as we consider changing the default for Pants to be warn or error (pantsbuild#15326).
  • Loading branch information
Eric-Arellano authored May 5, 2022
1 parent 27e2f79 commit 3687fd8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ lockfile_generator = "pex"

[python-infer]
assets = true
unowned_dependency_behavior = "error"

[docformatter]
args = ["--wrap-summaries=100", "--wrap-descriptions=100"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def valid_address(value: str) -> bool:

def main(cmd: str, args: list[str]) -> None:
# import here to allow the rest of the file to be tested without a dependency on dockerfile
from dockerfile import Command, parse_file, parse_string
from dockerfile import Command, parse_file, parse_string # pants: no-infer-dep

@dataclass(frozen=True)
class ParsedDockerfile:
Expand Down
5 changes: 3 additions & 2 deletions src/python/pants/backend/terraform/hcl2_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ def resolve_pure_path(base: PurePath, relative_path: PurePath) -> PurePath:


def extract_module_source_paths(path: PurePath, raw_content: bytes) -> Set[str]:
# Import here so we can still test this file with pytest (since `hcl2` is not present in normal Pants venv.)
import hcl2 # type: ignore[import]
# Import here so we can still test this file with pytest (since `hcl2` is not present in
# normal Pants venv.)
import hcl2 # type: ignore[import] # pants: no-infer-dep

content = raw_content.decode("utf-8")
parsed_content = hcl2.loads(content)
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/goal/stats_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __call__(

if not (self.log and self.has_histogram_module):
return
from hdrh.histogram import HdrHistogram
from hdrh.histogram import HdrHistogram # pants: no-infer-dep

histograms = context.get_observation_histograms()["histograms"]
if not histograms:
Expand Down
2 changes: 1 addition & 1 deletion testprojects/src/python/native/name.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from native import impl # type: ignore[attr-defined]
from native import impl # type: ignore[attr-defined] # pants: no-infer-dep


def get_name():
Expand Down

0 comments on commit 3687fd8

Please sign in to comment.