Skip to content

Commit

Permalink
Review feedback.
Browse files Browse the repository at this point in the history
# Rust tests will be skipped. Delete if not intended.
[ci skip-rust-tests]
  • Loading branch information
stuhood committed Jul 24, 2020
1 parent ef9eb3f commit 55b9a54
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
Expand Up @@ -163,3 +163,11 @@ async def map_module_to_address(
if first_party_address:
return PythonModuleOwner(first_party_address)
return PythonModuleOwner(address=None)


def rules():
return [
map_first_party_modules_to_addresses,
map_third_party_modules_to_addresses,
map_module_to_address,
]
16 changes: 5 additions & 11 deletions src/python/pants/backend/python/dependency_inference/rules.py
Expand Up @@ -3,14 +3,9 @@

from pathlib import PurePath

from pants.backend.python.dependency_inference import module_mapper
from pants.backend.python.dependency_inference.import_parser import find_python_imports
from pants.backend.python.dependency_inference.module_mapper import (
PythonModule,
PythonModuleOwner,
map_first_party_modules_to_addresses,
map_module_to_address,
map_third_party_modules_to_addresses,
)
from pants.backend.python.dependency_inference.module_mapper import PythonModule, PythonModuleOwner
from pants.backend.python.dependency_inference.python_stdlib.combined import combined_stdlib
from pants.backend.python.rules import inject_ancestor_files
from pants.backend.python.rules.inject_ancestor_files import AncestorFiles, AncestorFilesRequest
Expand All @@ -20,7 +15,7 @@
StripSourcesFieldRequest,
)
from pants.engine.fs import Digest, DigestContents
from pants.engine.internals.graph import Owners, OwnersNotFoundBehavior, OwnersRequest
from pants.engine.internals.graph import Owners, OwnersRequest
from pants.engine.rules import SubsystemRule, rule
from pants.engine.selectors import Get, MultiGet
from pants.engine.target import (
Expand All @@ -30,6 +25,7 @@
InferredDependencies,
)
from pants.engine.unions import UnionRule
from pants.option.global_options import OwnersNotFoundBehavior
from pants.subsystem.subsystem import Subsystem


Expand Down Expand Up @@ -163,14 +159,12 @@ async def infer_python_conftest_dependencies(
def rules():
return [
*inject_ancestor_files.rules(),
*module_mapper.rules(),
infer_python_dependencies,
infer_python_init_dependencies,
infer_python_conftest_dependencies,
UnionRule(InferDependenciesRequest, InferPythonDependencies),
UnionRule(InferDependenciesRequest, InferInitDependencies),
UnionRule(InferDependenciesRequest, InferConftestDependencies),
SubsystemRule(PythonInference),
map_first_party_modules_to_addresses,
map_third_party_modules_to_addresses,
map_module_to_address,
]
Expand Up @@ -120,7 +120,7 @@ def test_arithmetic():
(no_src_folder / "test_no_src.py").write_text("def test_true():\n\tassert True is True\n")
(no_src_folder / "BUILD").write_text(
dedent(
f"""\
"""\
python_tests()
python_library(name='lib')
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/rules/python_sources.py
Expand Up @@ -4,7 +4,6 @@
from dataclasses import dataclass
from typing import Iterable, List, Tuple, Type

from pants.backend.python.rules.inject_ancestor_files import rules as inject_ancestor_rules
from pants.backend.python.target_types import PythonSources
from pants.core.target_types import FilesSources, ResourcesSources
from pants.core.util_rules import determine_source_files
Expand Down
Expand Up @@ -113,6 +113,7 @@ def run_mypy(
"--backend-packages=pants.backend.python",
"--backend-packages=pants.backend.python.typecheck.mypy",
"--source-root-patterns=['src/python', 'tests/python']",
"--python-infer-imports",
]
if config:
self.create_file(relpath="mypy.ini", contents=config)
Expand Down Expand Up @@ -186,7 +187,6 @@ def test_skip(self) -> None:
assert not result

def test_transitive_dependencies(self) -> None:

self.create_file(f"{self.package}/util/__init__.py")
self.create_file(
f"{self.package}/util/lib.py",
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/engine/internals/graph.py
Expand Up @@ -345,7 +345,7 @@ def _log_or_raise_unmatched_owners(
) -> None:
msgs = []
if ignore_option:
option_msg = "\nIf you would like to ignore un-owned files, please pass `ignore_option`."
option_msg = f"\nIf you would like to ignore un-owned files, please pass `{ignore_option}`."
else:
option_msg = ""
for file_path in file_paths:
Expand Down Expand Up @@ -763,7 +763,7 @@ async def resolve_dependencies(
)

inference_request_types = union_membership.get(InferDependenciesRequest)
inferred = [InferredDependencies()]
inferred: Tuple[InferredDependencies, ...] = (InferredDependencies(),)
if inference_request_types:
# Dependency inference is solely determined by the `Sources` field for a Target, so we
# re-resolve the original target to inspect its `Sources` field, if any.
Expand Down

0 comments on commit 55b9a54

Please sign in to comment.