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

pantsbuild / pants / 21726110101

05 Feb 2026 07:49PM UTC coverage: 80.284% (-0.01%) from 80.296%
21726110101

push

github

web-flow
Support dep inference on multiple files in a single workunit (#23075)

Each file's result is still cached independently.

In large repos we schedule a large number of very fast
tasks, so the scheduling overhead dominates the runtime,
so processing many files in a batch is a win.

The Python-side code doesn't make use of this yet, so it
passes single files and receives singletons back.

A followup change can actually put this into action.

20 of 44 new or added lines in 5 files covered. (45.45%)

2 existing lines in 2 files now uncovered.

78530 of 97815 relevant lines covered (80.28%)

3.36 hits per line

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

75.47
/src/python/pants/engine/internals/native_dep_inference.py
1
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
12✔
5

6
from dataclasses import dataclass
12✔
7
from typing import AbstractSet, Sequence
12✔
8

9
from pants.util.frozendict import FrozenDict
12✔
10

11

12
@dataclass(frozen=True)
12✔
13
class NativePythonFileDependencies:
12✔
14
    imports: FrozenDict[str, tuple[int, bool]]
12✔
15
    string_candidates: FrozenDict[str, int]
12✔
16

17
    def __init__(self, imports: dict[str, tuple[int, bool]], string_candidates: dict[str, int]):
12✔
18
        object.__setattr__(self, "imports", FrozenDict(imports))
×
19
        object.__setattr__(self, "string_candidates", FrozenDict(string_candidates))
×
20

21

22
@dataclass(frozen=True)
12✔
23
class NativePythonFilesDependencies:
12✔
24
    path_to_deps: FrozenDict[str, NativePythonFileDependencies]
12✔
25

26

27
@dataclass(frozen=True)
12✔
28
class JavascriptDependencyCandidate:
12✔
29
    file_imports: frozenset[str]
12✔
30
    package_imports: frozenset[str]
12✔
31

32
    def __init__(self, file_imports: AbstractSet[str], package_imports: AbstractSet[str]):
12✔
NEW
33
        object.__setattr__(self, "file_imports", frozenset(file_imports))
×
NEW
34
        object.__setattr__(self, "package_imports", frozenset(package_imports))
×
35

36

37
@dataclass(frozen=True)
12✔
38
class NativeJavascriptFileDependencies:
12✔
39
    imports: FrozenDict[str, JavascriptDependencyCandidate]
12✔
40

41
    def __init__(self, imports: dict[str, JavascriptDependencyCandidate]):
12✔
NEW
42
        object.__setattr__(self, "imports", FrozenDict(imports))
×
43

44
    @property
12✔
45
    def file_imports(self) -> frozenset[str]:
12✔
46
        return frozenset(
×
47
            string for candidate in self.imports.values() for string in candidate.file_imports
48
        )
49

50
    @property
12✔
51
    def package_imports(self) -> frozenset[str]:
12✔
52
        return frozenset(
×
53
            string for candidate in self.imports.values() for string in candidate.package_imports
54
        )
55

56

57
@dataclass(frozen=True)
12✔
58
class NativeJavascriptFilesDependencies:
12✔
59
    path_to_deps: FrozenDict[str, NativeJavascriptFileDependencies]
12✔
60

61

62
@dataclass(frozen=True)
12✔
63
class NativeDockerfileInfo:
12✔
64
    source: str
12✔
65
    build_args: tuple[str, ...]  # "ARG_NAME=VALUE", ...
12✔
66
    copy_source_paths: tuple[str, ...]
12✔
67
    copy_build_args: tuple[str, ...]  # "ARG_NAME=UPSTREAM_TARGET_ADDRESS", ...
12✔
68
    from_image_build_args: tuple[str, ...]  # "ARG_NAME=UPSTREAM_TARGET_ADDRESS", ...
12✔
69
    version_tags: tuple[str, ...]  # "STAGE TAG", ...
12✔
70

71
    def __init__(
12✔
72
        self,
73
        source: str,
74
        build_args: Sequence[str],
75
        copy_source_paths: Sequence[str],
76
        copy_build_args: Sequence[str],
77
        from_image_build_args: Sequence[str],
78
        version_tags: Sequence[str],
79
    ):
NEW
80
        object.__setattr__(self, "source", source)
×
NEW
81
        object.__setattr__(self, "build_args", tuple(build_args))
×
NEW
82
        object.__setattr__(self, "copy_source_paths", tuple(copy_source_paths))
×
NEW
83
        object.__setattr__(self, "copy_build_args", tuple(copy_build_args))
×
NEW
84
        object.__setattr__(self, "from_image_build_args", tuple(from_image_build_args))
×
NEW
85
        object.__setattr__(self, "version_tags", tuple(version_tags))
×
86

87

88
@dataclass(frozen=True)
12✔
89
class NativeDockerfileInfos:
12✔
90
    path_to_infos: FrozenDict[str, NativeDockerfileInfo]
12✔
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