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

pantsbuild / pants / 26342152999

23 May 2026 07:59PM UTC coverage: 91.165% (-1.6%) from 92.792%
26342152999

push

github

web-flow
Run Linux ARM CI on Depot runners (#23363)

RunsOn is deprecating their v2 stack, and rather than migrate
to v3 we should use the resources kindly donated by Depot.

GitHub also now has Linux ARM runners, should we need them.

87305 of 95766 relevant lines covered (91.16%)

3.87 hits per line

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

0.0
/src/python/pants/backend/codegen/thrift/apache/python/python_thrift_module_mapper.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 import defaultdict
×
7
from pathlib import PurePath
×
8
from typing import DefaultDict
×
9

10
from pants.backend.codegen.thrift import thrift_parser
×
11
from pants.backend.codegen.thrift.target_types import AllThriftTargets, ThriftSourceField
×
12
from pants.backend.codegen.thrift.thrift_parser import ParsedThriftRequest, parse_thrift_file
×
13
from pants.backend.python.dependency_inference.module_mapper import (
×
14
    FirstPartyPythonMappingImpl,
15
    FirstPartyPythonMappingImplMarker,
16
    ModuleProvider,
17
    ModuleProviderType,
18
    ResolveName,
19
)
20
from pants.backend.python.subsystems.setup import PythonSetup
×
21
from pants.backend.python.target_types import PythonResolveField
×
22
from pants.engine.rules import collect_rules, concurrently, rule
×
23
from pants.engine.unions import UnionRule
×
24
from pants.util.logging import LogLevel
×
25

26

27
def thrift_path_to_py_modules(source_path: str, *, namespace: str | None) -> tuple[str, str]:
×
28
    prefix = namespace if namespace else PurePath(source_path).stem
×
29
    return f"{prefix}.ttypes", f"{prefix}.constants"
×
30

31

32
class PythonThriftMappingMarker(FirstPartyPythonMappingImplMarker):
×
33
    pass
×
34

35

36
@rule(desc="Creating map of Thrift targets to generated Python modules", level=LogLevel.DEBUG)
×
37
async def map_thrift_to_python_modules(
×
38
    thrift_targets: AllThriftTargets,
39
    python_setup: PythonSetup,
40
    _: PythonThriftMappingMarker,
41
) -> FirstPartyPythonMappingImpl:
42
    parsed_files = await concurrently(
×
43
        parse_thrift_file(ParsedThriftRequest(tgt[ThriftSourceField])) for tgt in thrift_targets
44
    )
45

46
    resolves_to_modules_to_providers: DefaultDict[
×
47
        ResolveName, DefaultDict[str, list[ModuleProvider]]
48
    ] = defaultdict(lambda: defaultdict(list))
49
    for tgt, parsed in zip(thrift_targets, parsed_files):
×
50
        resolve = tgt[PythonResolveField].normalized_value(python_setup)
×
51
        provider = ModuleProvider(tgt.address, ModuleProviderType.IMPL)
×
52
        m1, m2 = thrift_path_to_py_modules(
×
53
            source_path=tgt[ThriftSourceField].file_path, namespace=parsed.namespaces.get("py")
54
        )
55
        resolves_to_modules_to_providers[resolve][m1].append(provider)
×
56
        resolves_to_modules_to_providers[resolve][m2].append(provider)
×
57

58
    return FirstPartyPythonMappingImpl.create(resolves_to_modules_to_providers)
×
59

60

61
def rules():
×
62
    return (
×
63
        *collect_rules(),
64
        *thrift_parser.rules(),
65
        UnionRule(FirstPartyPythonMappingImplMarker, PythonThriftMappingMarker),
66
    )
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