• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 20332790708

18 Dec 2025 09:48AM UTC coverage: 64.992% (-15.3%) from 80.295%
20332790708

Pull #22949

github

web-flow
Merge f730a56cd into 407284c67
Pull Request #22949: Add experimental uv resolver for Python lockfiles

54 of 97 new or added lines in 5 files covered. (55.67%)

8270 existing lines in 295 files now uncovered.

48990 of 75379 relevant lines covered (64.99%)

1.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/codegen/protobuf/scala/dependency_inference.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
UNCOV
3
from __future__ import annotations
×
4

UNCOV
5
from dataclasses import dataclass
×
6

UNCOV
7
from pants.backend.codegen.protobuf.scala.subsystem import ScalaPBSubsystem
×
UNCOV
8
from pants.backend.codegen.protobuf.target_types import ProtobufDependenciesField
×
UNCOV
9
from pants.backend.scala.subsystems.scala import ScalaSubsystem
×
UNCOV
10
from pants.build_graph.address import Address
×
UNCOV
11
from pants.engine.rules import collect_rules, implicitly, rule
×
UNCOV
12
from pants.engine.target import FieldSet, InferDependenciesRequest, InferredDependencies
×
UNCOV
13
from pants.engine.unions import UnionRule
×
UNCOV
14
from pants.jvm.dependency_inference.artifact_mapper import (
×
15
    AllJvmArtifactTargets,
16
    find_jvm_artifacts_or_raise,
17
)
UNCOV
18
from pants.jvm.resolve.coordinate import Coordinate
×
UNCOV
19
from pants.jvm.subsystems import JvmSubsystem
×
UNCOV
20
from pants.jvm.target_types import JvmResolveField
×
21

UNCOV
22
_SCALAPB_RUNTIME_GROUP = "com.thesamet.scalapb"
×
UNCOV
23
_SCALAPB_RUNTIME_ARTIFACT = "scalapb-runtime"
×
24

25

UNCOV
26
@dataclass(frozen=True)
×
UNCOV
27
class ScalaPBRuntimeDependencyInferenceFieldSet(FieldSet):
×
UNCOV
28
    required_fields = (ProtobufDependenciesField, JvmResolveField)
×
29

UNCOV
30
    dependencies: ProtobufDependenciesField
×
UNCOV
31
    resolve: JvmResolveField
×
32

33

UNCOV
34
class InferScalaPBRuntimeDependencyRequest(InferDependenciesRequest):
×
UNCOV
35
    infer_from = ScalaPBRuntimeDependencyInferenceFieldSet
×
36

37

UNCOV
38
@dataclass(frozen=True)
×
UNCOV
39
class ScalaPBRuntimeForResolveRequest:
×
UNCOV
40
    resolve_name: str
×
41

42

UNCOV
43
@dataclass(frozen=True)
×
UNCOV
44
class ScalaPBRuntimeForResolve:
×
UNCOV
45
    addresses: frozenset[Address]
×
46

47

UNCOV
48
@rule
×
UNCOV
49
async def resolve_scalapb_runtime_for_resolve(
×
50
    request: ScalaPBRuntimeForResolveRequest,
51
    jvm_artifact_targets: AllJvmArtifactTargets,
52
    jvm: JvmSubsystem,
53
    scala_subsystem: ScalaSubsystem,
54
    scalapb: ScalaPBSubsystem,
55
) -> ScalaPBRuntimeForResolve:
56
    scala_version = scala_subsystem.version_for_resolve(request.resolve_name)
×
57
    scala_binary_version = scala_version.binary
×
58
    version = scalapb.version
×
59

60
    addresses = find_jvm_artifacts_or_raise(
×
61
        required_coordinates=[
62
            Coordinate(
63
                group=_SCALAPB_RUNTIME_GROUP,
64
                artifact=f"{_SCALAPB_RUNTIME_ARTIFACT}_{scala_binary_version}",
65
                version=version,
66
            )
67
        ],
68
        resolve=request.resolve_name,
69
        jvm_artifact_targets=jvm_artifact_targets,
70
        jvm=jvm,
71
        subsystem="the ScalaPB runtime",
72
        target_type="protobuf_sources",
73
        requirement_source="the `[scalapb].version` option",
74
    )
75
    return ScalaPBRuntimeForResolve(addresses)
×
76

77

UNCOV
78
@rule
×
UNCOV
79
async def infer_scalapb_runtime_dependency(
×
80
    request: InferScalaPBRuntimeDependencyRequest,
81
    jvm: JvmSubsystem,
82
) -> InferredDependencies:
83
    resolve = request.field_set.resolve.normalized_value(jvm)
×
84

85
    scalapb_runtime_target_info = await resolve_scalapb_runtime_for_resolve(
×
86
        ScalaPBRuntimeForResolveRequest(resolve), **implicitly()
87
    )
88
    return InferredDependencies(scalapb_runtime_target_info.addresses)
×
89

90

UNCOV
91
def rules():
×
UNCOV
92
    return (
×
93
        *collect_rules(),
94
        UnionRule(InferDependenciesRequest, InferScalaPBRuntimeDependencyRequest),
95
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc