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

pantsbuild / pants / 25259185675

02 May 2026 06:47PM UTC coverage: 92.141% (-0.8%) from 92.955%
25259185675

push

github

web-flow
Fix the dynamic UI. (#23306)

In #23114 we upgraded to indicatif 0.18.4,
which included a fix to respect TERM, and 
display nothing if it's unset.

Since we did not pass TERM through pantsd, the
dynamic ui is now not shown. 

This change fixes that, and also pass NO_COLOR
through, since indicatif inspects it too.

88773 of 96345 relevant lines covered (92.14%)

3.83 hits per line

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

70.27
/src/python/pants/backend/go/util_rules/embedcfg.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
10✔
5

6
import json
10✔
7
from collections.abc import Iterable, Mapping
10✔
8
from dataclasses import dataclass
10✔
9
from typing import Any
10✔
10

11
from pants.util.frozendict import FrozenDict
10✔
12
from pants.util.strutil import strip_prefix
10✔
13

14

15
@dataclass(frozen=True)
10✔
16
class EmbedConfig:
10✔
17
    patterns: FrozenDict[str, tuple[str, ...]]
10✔
18
    files: FrozenDict[str, str]
10✔
19

20
    def __init__(self, patterns: Mapping[str, Iterable[str]], files: Mapping[str, str]) -> None:
10✔
21
        """Configuration passed to the Go compiler to configure file embedding.
22

23
        The compiler relies entirely on the caller to map embed patterns to actual filesystem
24
        paths. All embed patterns
25
        contained in the package must be mapped. Consult
26
        `FirstPartyPkgAnalysis.embed_patterns` for the embed patterns obtained from analysis.
27

28
        :param patterns: Maps each pattern provided via a //go:embed directive to a list of file
29
          paths relative to the package directory for files to embed for that pattern. When the
30
          embedded variable is an `embed.FS`, those relative file paths define the virtual
31
          directory hierarchy exposed by the embed.FS filesystem abstraction. The relative file
32
          paths are resolved to actual filesystem paths for their content by consulting the
33
          `files` dictionary.
34
        :param files: Maps each virtual, relative file path used as a value in the `patterns`
35
          dictionary to the actual filesystem path with that file's content.
36
        """
37
        object.__setattr__(self, "patterns", FrozenDict({k: tuple(v) for k, v in patterns.items()}))
1✔
38
        object.__setattr__(self, "files", FrozenDict(files))
1✔
39

40
    @classmethod
10✔
41
    def from_json_dict(
10✔
42
        cls, d: dict[str, Any], prefix_to_strip: str | None = None
43
    ) -> EmbedConfig | None:
44
        patterns = d.get("Patterns", {})
1✔
45
        files = d.get("Files", {})
1✔
46
        if prefix_to_strip:
1✔
47
            files = {key: strip_prefix(value, prefix_to_strip) for key, value in files.items()}
1✔
48
        result = cls(
1✔
49
            patterns=FrozenDict({key: tuple(value) for key, value in patterns.items()}),
50
            files=FrozenDict(files),
51
        )
52
        return result if result else None
1✔
53

54
    def to_embedcfg(self) -> bytes:
10✔
55
        data = {
×
56
            "Patterns": dict(self.patterns),
57
            "Files": dict(self.files),
58
        }
59
        return json.dumps(data).encode("utf-8")
×
60

61
    def __bool__(self) -> bool:
10✔
62
        return bool(self.patterns) or bool(self.files)
1✔
63

64
    def merge(self, other: EmbedConfig) -> EmbedConfig:
10✔
65
        """Merge two EmbedConfig's into one.
66

67
        Overlapping keys must have the same values.
68
        """
69
        overlapping_patterns_keys = set(self.patterns.keys()) & set(other.patterns.keys())
×
70
        for key in overlapping_patterns_keys:
×
71
            if self.patterns[key] != other.patterns[key]:
×
72
                raise AssertionError(
×
73
                    "Unable to merge conflicting golang file embed configurations. This should not have occurred. "
74
                    "Please open an issue at https://github.com/pantsbuild/pants/issues/new/choose "
75
                    "with the following information: "
76
                    f"Patterns Key: {key}; Left: {self.patterns[key]}; Right: {other.patterns[key]} "
77
                )
78

79
        overlapping_files_keys = set(self.files.keys()) & set(other.files.keys())
×
80
        for key in overlapping_files_keys:
×
81
            if self.files[key] != other.files[key]:
×
82
                raise AssertionError(
×
83
                    "Unable to merge conflicting golang file embed configurations. This should not have occurred. "
84
                    "Please open an issue at https://github.com/pantsbuild/pants/issues/new/choose "
85
                    "with the following information: "
86
                    f"Files Key: {key}; Left: {self.patterns[key]}; Right: {other.patterns[key]} "
87
                )
88

89
        return EmbedConfig(
×
90
            patterns={**self.patterns, **other.patterns},
91
            files={**self.files, **other.files},
92
        )
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