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

pantsbuild / pants / 24055979590

06 Apr 2026 11:17PM UTC coverage: 52.37% (-40.5%) from 92.908%
24055979590

Pull #23225

github

web-flow
Merge 67474653c into 542ca048d
Pull Request #23225: Add --test-show-all-batch-targets to expose all targets in batched pytest

6 of 17 new or added lines in 2 files covered. (35.29%)

23030 existing lines in 605 files now uncovered.

31643 of 60422 relevant lines covered (52.37%)

1.05 hits per line

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

0.0
/src/python/pants/backend/openapi/util_rules/pom_parser.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
import xml.etree.ElementTree as ET
×
UNCOV
7
from dataclasses import dataclass
×
8

UNCOV
9
from pants.engine.fs import Digest
×
UNCOV
10
from pants.engine.intrinsics import get_digest_contents
×
UNCOV
11
from pants.engine.rules import collect_rules, rule
×
UNCOV
12
from pants.jvm.resolve.coordinate import Coordinate
×
13

14

UNCOV
15
@dataclass(frozen=True)
×
UNCOV
16
class AnalysePomRequest:
×
UNCOV
17
    pom_digest: Digest
×
18

19

UNCOV
20
@dataclass(frozen=True)
×
UNCOV
21
class PomReport:
×
UNCOV
22
    dependencies: tuple[Coordinate, ...]
×
23

24

UNCOV
25
_MAVEN_NAMESPACE = "http://maven.apache.org/POM/4.0.0"
×
UNCOV
26
_MAVEN_NAMESPACE_MAP = {"mvn": _MAVEN_NAMESPACE}
×
27

28

UNCOV
29
@rule(desc="Analysing Maven POM file")
×
UNCOV
30
async def analyse_pom(request: AnalysePomRequest) -> PomReport:
×
UNCOV
31
    contents = await get_digest_contents(request.pom_digest)
×
UNCOV
32
    assert len(contents) == 1
×
33

UNCOV
34
    root = ET.fromstring(contents[0].content)
×
35

UNCOV
36
    def maybe_lookup_property(txt: str | None) -> str | None:
×
UNCOV
37
        if not txt:
×
UNCOV
38
            return None
×
39

UNCOV
40
        if txt.startswith("${") and txt.endswith("}"):
×
UNCOV
41
            prop = txt[2:-1]
×
UNCOV
42
            prop_value = root.findtext(
×
43
                f".//mvn:properties/mvn:{prop}", namespaces=_MAVEN_NAMESPACE_MAP
44
            )
UNCOV
45
            if prop_value:
×
UNCOV
46
                return prop_value
×
UNCOV
47
        return txt
×
48

UNCOV
49
    coordinates = []
×
UNCOV
50
    for dep in root.findall(".//mvn:dependency", namespaces=_MAVEN_NAMESPACE_MAP):
×
UNCOV
51
        scope = maybe_lookup_property(dep.findtext("mvn:scope", namespaces=_MAVEN_NAMESPACE_MAP))
×
UNCOV
52
        if scope and scope == "test":
×
UNCOV
53
            continue
×
54

UNCOV
55
        coord_dict = {
×
56
            "artifact": maybe_lookup_property(
57
                dep.findtext("mvn:artifactId", namespaces=_MAVEN_NAMESPACE_MAP)
58
            ),
59
            "group": maybe_lookup_property(
60
                dep.findtext("mvn:groupId", namespaces=_MAVEN_NAMESPACE_MAP)
61
            ),
62
            "version": maybe_lookup_property(
63
                dep.findtext("mvn:version", namespaces=_MAVEN_NAMESPACE_MAP)
64
            ),
65
            "packaging": maybe_lookup_property(
66
                dep.findtext("mvn:packaging", default="jar", namespaces=_MAVEN_NAMESPACE_MAP)
67
            ),
68
            "classifier": maybe_lookup_property(
69
                dep.findtext("mvn:classifier", namespaces=_MAVEN_NAMESPACE_MAP)
70
            ),
71
        }
UNCOV
72
        coordinates.append(Coordinate.from_json_dict(coord_dict))
×
73

UNCOV
74
    return PomReport(tuple(coordinates))
×
75

76

UNCOV
77
def rules():
×
UNCOV
78
    return collect_rules()
×
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

© 2026 Coveralls, Inc