Skip to content

Commit

Permalink
Restore support for third-party requirements with MyPy
Browse files Browse the repository at this point in the history
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano committed Sep 18, 2020
1 parent 519a6cc commit ba7a68c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
27 changes: 14 additions & 13 deletions src/python/pants/backend/python/typecheck/mypy/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import itertools
from dataclasses import dataclass
from pathlib import PurePath
from textwrap import dedent
from typing import Tuple

Expand All @@ -20,6 +21,7 @@
PexRequest,
PexRequirements,
)
from pants.backend.python.util_rules.pex_from_targets import PexFromTargetsRequest
from pants.backend.python.util_rules.python_sources import (
PythonSourceFiles,
PythonSourceFilesRequest,
Expand Down Expand Up @@ -195,28 +197,27 @@ async def mypy_typecheck(
entry_point=mypy.entry_point,
),
)
# requirements_pex_request = Get(
# Pex,
# PexFromTargetsRequest,
# PexFromTargetsRequest.for_requirements(
# (field_set.address for field_set in request.field_sets), internal_only=True
# ),
# )
requirements_pex_request = Get(
Pex,
PexFromTargetsRequest,
PexFromTargetsRequest.for_requirements(
(field_set.address for field_set in request.field_sets), internal_only=True
),
)
runner_pex_request = Get(
Pex,
PexRequest(
output_filename="mypy_runner.pex",
internal_only=True,
sources=launcher_script,
interpreter_constraints=PexInterpreterConstraints(tool_interpreter_constraints),
# entry_point=PurePath(LAUNCHER_FILE.path).stem,
entry_point=mypy.entry_point,
entry_point=PurePath(LAUNCHER_FILE.path).stem,
additional_args=(
"--pex-path",
":".join(
(
tool_pex_request.input.output_filename,
# requirements_pex_request.subject.output_filename,
requirements_pex_request.input.output_filename,
)
),
),
Expand All @@ -236,14 +237,14 @@ async def mypy_typecheck(
plugin_sources,
typechecked_sources,
tool_pex,
# requirements_pex,
requirements_pex,
runner_pex,
config_digest,
) = await MultiGet(
plugin_sources_request,
typechecked_sources_request,
tool_pex_request,
# requirements_pex_request,
requirements_pex_request,
runner_pex_request,
config_digest_request,
)
Expand All @@ -266,7 +267,7 @@ async def mypy_typecheck(
plugin_sources.source_files.snapshot.digest,
typechecked_srcs_snapshot.digest,
tool_pex.digest,
# requirements_pex.digest,
requirements_pex.digest,
runner_pex.digest,
config_digest,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ def test_skip(rule_runner: RuleRunner) -> None:
assert not result


@pytest.mark.xfail(reason="Temporarily disabled 3rd-party support")
def test_thirdparty_dependency(rule_runner: RuleRunner) -> None:
rule_runner.add_to_build_file(
"",
Expand Down Expand Up @@ -229,7 +228,6 @@ def test_thirdparty_dependency(rule_runner: RuleRunner) -> None:
assert f"{PACKAGE}/itertools.py:3" in result[0].stdout


@pytest.mark.xfail(reason="Temporarily disabled 3rd-party support")
def test_thirdparty_plugin(rule_runner: RuleRunner) -> None:
rule_runner.add_to_build_file(
"",
Expand Down Expand Up @@ -371,7 +369,6 @@ def test_works_with_python38(rule_runner: RuleRunner) -> None:
assert "Success: no issues found" in result[0].stdout.strip()


@pytest.mark.xfail(reason="Temporarily disabled 3rd-party support, and this plugin uses that")
def test_source_plugin(rule_runner: RuleRunner) -> None:
# NB: We make this source plugin fairly complex by having it use transitive dependencies.
# This is to ensure that we can correctly support plugins with dependencies.
Expand Down

0 comments on commit ba7a68c

Please sign in to comment.