Skip to content

Commit

Permalink
Renames hex_digest to requirements_hex_digest
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
Christopher Neugebauer committed Aug 16, 2021
1 parent 7ef6181 commit ca1f2b0
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/backend/awslambda/python/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def package_python_awslambda(
lockfile_hex_digest = None
if lambdex.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, LambdexLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

lambdex_request = PexRequest(
output_filename="lambdex.pex",
Expand Down
10 changes: 3 additions & 7 deletions src/python/pants/backend/experimental/python/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,8 @@ def from_tool(
)

@property
def hex_digest(self) -> str:
"""Produces a hex digest of this lockfile's inputs, which should uniquely specify the
resolution of this lockfile request.
Inputs are defined as requirements.
"""
def requirements_hex_digest(self) -> str:
"""Produces a hex digest of the requirements input for this lockfile."""
return calculate_invalidation_digest(self.requirements)


Expand Down Expand Up @@ -170,7 +166,7 @@ async def generate_lockfile(
lockfile_digest_contents = await Get(DigestContents, Digest, poetry_export_result.output_digest)
lockfile_with_header = lockfile_content_with_header(
python_setup.lockfile_custom_regeneration_command or req.regenerate_command,
req.hex_digest,
req.requirements_hex_digest,
req.interpreter_constraints,
lockfile_digest_contents[0].content,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def is_valid_for(
# This lockfile matches all interpreter constraints (TODO: check this)
return True

return self.valid_interpreter_constraints.contains(user_interpreter_constraints, interpreter_universe)
return self.valid_interpreter_constraints.contains(
user_interpreter_constraints, interpreter_universe
)


def calculate_invalidation_digest(
Expand Down Expand Up @@ -132,7 +134,7 @@ def yield_metadata_lines() -> Iterable[bytes]:
T = TypeVar("T")

def coerce(t: Callable[[Any], T], key: str) -> T | None:
""" Gets a value from `metadata`, coercing it to type `t` if not `None`."""
"""Gets a value from `metadata`, coercing it to type `t` if not `None`."""
v = metadata.get(key, None)
try:
return t(v) if v is not None else None
Expand All @@ -142,5 +144,7 @@ def coerce(t: Callable[[Any], T], key: str) -> T | None:

return LockfileMetadata(
invalidation_digest=coerce(str, "invalidation_digest"),
valid_interpreter_constraints=coerce(InterpreterConstraints, "valid_interpreter_constraints"),
valid_interpreter_constraints=coerce(
InterpreterConstraints, "valid_interpreter_constraints"
),
)
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/goals/coverage_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async def setup_coverage(coverage: CoverageSubsystem) -> CoverageSetup:
lockfile_hex_digest = None
if coverage.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, CoveragePyLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

pex = await Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/goals/setup_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ async def run_setup_py(req: RunSetupPyRequest, setuptools: Setuptools) -> RunSet
lockfile_hex_digest = None
if setuptools.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, SetuptoolsLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

setuptools_pex = await Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/bandit/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def bandit_lint_partition(partition: BanditPartition, bandit: Bandit) -> L
lockfile_hex_digest = None
if bandit.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, BanditLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

bandit_pex_get = Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/black/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def setup_black(
lockfile_hex_digest = None
if black.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, BlackLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

black_pex_get = Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/docformatter/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def setup_docformatter(setup_request: SetupRequest, docformatter: Docforma
lockfile_hex_digest = None
if docformatter.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, DocformatterLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

docformatter_pex_get = Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/flake8/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def flake8_lint_partition(partition: Flake8Partition, flake8: Flake8) -> L
lockfile_hex_digest = None
if flake8.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, Flake8LockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

flake8_pex_get = Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/isort/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def setup_isort(setup_request: SetupRequest, isort: Isort) -> Setup:
lockfile_hex_digest = None
if isort.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, IsortLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

isort_pex_get = Get(
VenvPex,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/yapf/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def setup_yapf(setup_request: SetupRequest, yapf: Yapf) -> Setup:
lockfile_hex_digest = None
if yapf.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, YapfLockfileSentinel())
lockfile_hex_digest = lockfile_request.hex_digest
lockfile_hex_digest = lockfile_request.requirements_hex_digest

yapf_pex_get = Get(
VenvPex,
Expand Down

0 comments on commit ca1f2b0

Please sign in to comment.