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

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

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

0.0
/src/python/pants/backend/openapi/goals/tailor.py
1
# Copyright 2022 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 itertools
×
UNCOV
7
from collections.abc import Iterable
×
UNCOV
8
from dataclasses import dataclass
×
9

UNCOV
10
from pants.backend.openapi.dependency_inference import ParseOpenApiSources, parse_openapi_sources
×
UNCOV
11
from pants.backend.openapi.subsystems.openapi import OpenApiSubsystem
×
UNCOV
12
from pants.backend.openapi.target_types import (
×
13
    OPENAPI_FILE_EXTENSIONS,
14
    OpenApiDocumentGeneratorTarget,
15
    OpenApiSourceGeneratorTarget,
16
)
UNCOV
17
from pants.core.goals.tailor import (
×
18
    AllOwnedSources,
19
    PutativeTarget,
20
    PutativeTargets,
21
    PutativeTargetsRequest,
22
)
UNCOV
23
from pants.engine.fs import PathGlobs
×
UNCOV
24
from pants.engine.intrinsics import path_globs_to_digest, path_globs_to_paths
×
UNCOV
25
from pants.engine.rules import Rule, collect_rules, rule
×
UNCOV
26
from pants.engine.unions import UnionRule
×
UNCOV
27
from pants.util.dirutil import group_by_dir
×
UNCOV
28
from pants.util.logging import LogLevel
×
29

30

UNCOV
31
@dataclass(frozen=True)
×
UNCOV
32
class PutativeOpenApiTargetsRequest(PutativeTargetsRequest):
×
UNCOV
33
    pass
×
34

35

UNCOV
36
@rule(level=LogLevel.DEBUG, desc="Determine candidate OpenAPI targets to create")
×
UNCOV
37
async def find_putative_targets(
×
38
    req: PutativeOpenApiTargetsRequest,
39
    all_owned_sources: AllOwnedSources,
40
    openapi_subsystem: OpenApiSubsystem,
41
) -> PutativeTargets:
42
    if not openapi_subsystem.tailor_targets:
×
43
        return PutativeTargets()
×
44

45
    all_openapi_files = await path_globs_to_paths(
×
46
        req.path_globs(*(f"**/openapi{ext}" for ext in OPENAPI_FILE_EXTENSIONS))
47
    )
48
    targets = {*all_openapi_files.files}
×
49
    paths = tuple(targets)
×
50

51
    while paths:
×
52
        digest = await path_globs_to_digest(PathGlobs(paths))  # noqa: PNT30: this is inherently sequential
×
53
        result = await parse_openapi_sources(
×
54
            ParseOpenApiSources(
55
                sources_digest=digest,
56
                paths=tuple(paths),
57
            )
58
        )
59

60
        targets.update(result.dependencies.keys())
×
61
        paths = tuple(v for v in itertools.chain(*result.dependencies.values()) if v not in targets)
×
62

63
    unowned_openapi_documents = set(all_openapi_files.files) - set(all_owned_sources)
×
64
    unowned_openapi_sources = targets - set(all_owned_sources)
×
65
    classified_unowned_openapi_files = {
×
66
        OpenApiDocumentGeneratorTarget: unowned_openapi_documents,
67
        OpenApiSourceGeneratorTarget: unowned_openapi_sources,
68
    }
69

70
    putative_targets = []
×
71
    for tgt_type, filepaths in classified_unowned_openapi_files.items():
×
72
        for dirname, filenames in group_by_dir(filepaths).items():
×
73
            name = "openapi" if tgt_type == OpenApiDocumentGeneratorTarget else None
×
74
            putative_targets.append(
×
75
                PutativeTarget.for_target_type(
76
                    tgt_type, path=dirname, name=name, triggering_sources=sorted(filenames)
77
                )
78
            )
79

80
    return PutativeTargets(putative_targets)
×
81

82

UNCOV
83
def rules() -> Iterable[Rule | UnionRule]:
×
UNCOV
84
    return (
×
85
        *collect_rules(),
86
        UnionRule(PutativeTargetsRequest, PutativeOpenApiTargetsRequest),
87
    )
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