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

pantsbuild / pants / 22740642519

05 Mar 2026 11:00PM UTC coverage: 52.677% (-40.3%) from 92.931%
22740642519

Pull #23157

github

web-flow
Merge 2aa18e6d4 into f0030f5e7
Pull Request #23157: [pants ng] Partition source files by config.

31678 of 60136 relevant lines covered (52.68%)

0.53 hits per line

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

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

4
from __future__ import annotations
1✔
5

6
from dataclasses import dataclass
1✔
7

8
from pants.backend.docker.subsystems.docker_options import DockerOptions
1✔
9
from pants.backend.docker.target_types import DockerImageBuildArgsField
1✔
10
from pants.backend.docker.utils import KeyValueSequenceUtil
1✔
11
from pants.engine.rules import collect_rules, rule
1✔
12
from pants.engine.target import Target
1✔
13

14

15
class DockerBuildArgs(KeyValueSequenceUtil):
1✔
16
    """Collection of arguments to pass to a Docker build."""
17

18
    def nonempty(self) -> dict[str, str]:
1✔
19
        return {k: v for k, v in self.to_dict().items() if v}
×
20

21
    def with_overrides(self, overrides: DockerBuildArgs) -> DockerBuildArgs:
1✔
22
        """Override the values in this collection.
23

24
        Will not extend with keys in overrides which do not exist in this collection.
25
        """
26
        overrides_dict = overrides.to_dict()
×
27
        return DockerBuildArgs.from_dict(
×
28
            {k: overrides_dict.get(k, v) for k, v in self.to_dict().items()}
29
        )
30

31
    def extended(self, more: DockerBuildArgs | list[str]) -> DockerBuildArgs:
1✔
32
        """Create a new DockerBuildArgs out of this and a list of strs to add."""
33
        if isinstance(more, DockerBuildArgs):
×
34
            return DockerBuildArgs.from_strings(*self, *more)
×
35
        else:
36
            return DockerBuildArgs.from_strings(*self, *more)
×
37

38

39
@dataclass(frozen=True)
1✔
40
class DockerBuildArgsRequest:
1✔
41
    target: Target
1✔
42

43

44
@rule
1✔
45
async def docker_build_args(
1✔
46
    request: DockerBuildArgsRequest, docker_options: DockerOptions
47
) -> DockerBuildArgs:
48
    return DockerBuildArgs.from_strings(
×
49
        *docker_options.build_args,
50
        *(request.target.get(DockerImageBuildArgsField).value or ()),
51
    )
52

53

54
def rules():
1✔
55
    return collect_rules()
1✔
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