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

pantsbuild / pants / 18517631058

15 Oct 2025 04:18AM UTC coverage: 69.207% (-11.1%) from 80.267%
18517631058

Pull #22745

github

web-flow
Merge 642a76ca1 into 99919310e
Pull Request #22745: [windows] Add windows support in the stdio crate.

53815 of 77759 relevant lines covered (69.21%)

2.42 hits per line

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

0.0
/src/python/pants/backend/swift/goals/tailor.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
×
5

6
from collections.abc import Iterable
×
7
from dataclasses import dataclass
×
8

9
from pants.backend.swift.target_types import SWIFT_FILE_EXTENSIONS, SwiftSourcesGeneratorTarget
×
10
from pants.core.goals.tailor import (
×
11
    AllOwnedSources,
12
    PutativeTarget,
13
    PutativeTargets,
14
    PutativeTargetsRequest,
15
)
16
from pants.engine.intrinsics import path_globs_to_paths
×
17
from pants.engine.rules import Rule, collect_rules, rule
×
18
from pants.engine.target import Target
×
19
from pants.engine.unions import UnionRule
×
20
from pants.util.dirutil import group_by_dir
×
21
from pants.util.logging import LogLevel
×
22

23

24
@dataclass(frozen=True)
×
25
class PutativeSwiftTargetsRequest(PutativeTargetsRequest):
×
26
    pass
×
27

28

29
def classify_source_files(paths: Iterable[str]) -> dict[type[Target], set[str]]:
×
30
    """Returns a dict of target type -> files that belong to targets of that type."""
31
    sources_files = set(paths)
×
32
    return {SwiftSourcesGeneratorTarget: sources_files}
×
33

34

35
@rule(level=LogLevel.DEBUG, desc="Determine candidate Swift targets to create")
×
36
async def find_putative_targets(
×
37
    req: PutativeSwiftTargetsRequest,
38
    all_owned_sources: AllOwnedSources,
39
) -> PutativeTargets:
40
    all_swift_files = await path_globs_to_paths(
×
41
        req.path_globs(*(f"*{ext}" for ext in SWIFT_FILE_EXTENSIONS))
42
    )
43
    unowned_swift_files = set(all_swift_files.files) - set(all_owned_sources)
×
44
    classified_unowned_swift_files = classify_source_files(unowned_swift_files)
×
45

46
    putative_targets = []
×
47
    for tgt_type, paths in classified_unowned_swift_files.items():
×
48
        for dirname, filenames in group_by_dir(paths).items():
×
49
            putative_targets.append(
×
50
                PutativeTarget.for_target_type(
51
                    tgt_type, path=dirname, name=None, triggering_sources=sorted(filenames)
52
                )
53
            )
54

55
    return PutativeTargets(putative_targets)
×
56

57

58
def rules() -> Iterable[Rule | UnionRule]:
×
59
    return (
×
60
        *collect_rules(),
61
        UnionRule(PutativeTargetsRequest, PutativeSwiftTargetsRequest),
62
    )
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