Skip to content

Commit

Permalink
[internal] cleanup usage of sorted (pantsbuild#14470)
Browse files Browse the repository at this point in the history
[ci skip-rust]
  • Loading branch information
asherf authored Feb 14, 2022
1 parent bf105b8 commit 6757baa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/backend/java/compile/javac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_compile_multiple_source_files(rule_runner: RuleRunner) -> None:
assert all(len(ctgt.members) == 1 for ctgt in coarsened_targets)

coarsened_targets_sorted = sorted(
list(coarsened_targets), key=lambda ctgt: str(list(ctgt.members)[0].address)
coarsened_targets, key=lambda ctgt: str(list(ctgt.members)[0].address)
)

request0 = CompileJavaSourceRequest(
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/util_rules/local_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def build_local_dists(

# We check source roots in reverse lexicographic order,
# so we'll find the innermost root that matches.
source_roots = list(reversed(sorted(request.sources.source_roots)))
source_roots = sorted(request.sources.source_roots, reverse=True)
remaining_sources = set(request.sources.source_files.files)
unrooted_files_set = set(request.sources.source_files.unrooted_files)
for source in request.sources.source_files.files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def to_debug_json_dict(self) -> dict[str, Any]:
for key, values in self.imports_by_scope.items()
},
"consumed_symbols_by_scope": {
k: sorted(list(v)) for k, v in self.consumed_symbols_by_scope.items()
k: sorted(v) for k, v in self.consumed_symbols_by_scope.items()
},
"scopes": list(self.scopes),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def this(bar: SomeTypeInSecondaryConstructor) {
),
)

assert sorted(list(analysis.provided_symbols)) == [
assert sorted(analysis.provided_symbols) == [
"org.pantsbuild.example.ASubClass",
"org.pantsbuild.example.ASubTrait",
"org.pantsbuild.example.Functions",
Expand Down Expand Up @@ -169,7 +169,7 @@ def this(bar: SomeTypeInSecondaryConstructor) {
"org.pantsbuild.example.OuterTrait.NestedVar",
]

assert sorted(list(analysis.provided_symbols_encoded)) == [
assert sorted(analysis.provided_symbols_encoded) == [
"org.pantsbuild.example.ASubClass",
"org.pantsbuild.example.ASubTrait",
"org.pantsbuild.example.Functions",
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/engine/internals/graph_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ def assert_coarsened(
CoarsenedTargets,
[Addresses([a])],
)
assert list(sorted(t.address for t in coarsened_targets[0].members)) == expected_members
assert sorted(t.address for t in coarsened_targets[0].members) == expected_members
# NB: Only the direct dependencies are compared.
assert (
list(sorted(d.address for ct in coarsened_targets[0].dependencies for d in ct.members))
sorted(d.address for ct in coarsened_targets[0].dependencies for d in ct.members)
== expected_dependencies
)

Expand Down Expand Up @@ -1927,7 +1927,7 @@ def assert_injected(deps_cls: Type[Dependencies], *, injected: List[Address]) ->
provided_deps.append("!//:injected2")
deps_field = deps_cls(provided_deps, Address("", target_name="target"))
result = dependencies_rule_runner.request(Addresses, [DependenciesRequest(deps_field)])
assert result == Addresses(sorted([*injected, Address("", target_name="provided")]))
assert result == Addresses(sorted((*injected, Address("", target_name="provided"))))

assert_injected(Dependencies, injected=[])
assert_injected(SmalltalkDependencies, injected=[Address("", target_name="injected1")])
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/goal/run_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def maybe_hash_with_repo_id_prefix(s: str) -> str:
"standard_goals": [goal for goal in self.goals if goal in self.STANDARD_GOALS],
# Lets us know of any custom goals were used, without knowing their names.
"num_goals": str(len(self.goals)),
"active_standard_backends": sorted(list(self.active_standard_backends)),
"active_standard_backends": sorted(self.active_standard_backends),
}

def set_pantsd_scheduler_metrics(self, metrics: dict[str, int]) -> None:
Expand Down

0 comments on commit 6757baa

Please sign in to comment.