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

pantsbuild / pants / 18812500213

26 Oct 2025 03:42AM UTC coverage: 80.284% (+0.005%) from 80.279%
18812500213

Pull #22804

github

web-flow
Merge 2a56fdb46 into 4834308dc
Pull Request #22804: test_shell_command: use correct default cache scope for a test's environment

29 of 31 new or added lines in 2 files covered. (93.55%)

1314 existing lines in 64 files now uncovered.

77900 of 97030 relevant lines covered (80.28%)

3.35 hits per line

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

91.67
/src/python/pants/backend/nfpm/fields/scripts.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
7✔
5

6
import os
7✔
7
from typing import ClassVar
7✔
8

9
from pants.engine.internals.native_engine import Address
7✔
10
from pants.engine.target import AsyncFieldMixin, DictStringToStringField, InvalidFieldException
7✔
11
from pants.util.frozendict import FrozenDict
7✔
12

13

14
class NfpmPackageScriptsField(AsyncFieldMixin, DictStringToStringField):
7✔
15
    nfpm_alias = ""  # maps to more than one nfpm.yaml field
7✔
16
    alias: ClassVar[str] = "scripts"
7✔
17
    # The keys of nfpm_aliases are the only valid keys of this field.
18
    nfpm_aliases: ClassVar[FrozenDict[str, str]] = FrozenDict(
7✔
19
        {
20
            # The general scripts common to all packager types
21
            "preinstall": "scripts.preinstall",
22
            "postinstall": "scripts.postinstall",
23
            "preremove": "scripts.preremove",
24
            "postremove": "scripts.postremove",
25
        }
26
    )
27

28
    @classmethod
7✔
29
    def compute_value(
7✔
30
        cls, raw_value: dict[str, str] | None, address: Address
31
    ) -> FrozenDict[str, str] | None:
32
        value_or_default = super().compute_value(raw_value, address)
2✔
33
        if value_or_default:
2✔
UNCOV
34
            invalid_keys = value_or_default.keys() - cls.nfpm_aliases.keys()
1✔
UNCOV
35
            if invalid_keys:
1✔
36
                raise InvalidFieldException(
×
37
                    f"Each key for the '{cls.alias}' field in target {address} must be one of"
38
                    f"{repr(tuple(cls.nfpm_aliases.keys()))}, but {repr(invalid_keys)} was provided.",
39
                )
40
        return value_or_default
2✔
41

42
    @property
7✔
43
    def normalized_value(self) -> FrozenDict[str, str]:
7✔
UNCOV
44
        value = self.value
1✔
UNCOV
45
        if not value:
1✔
46
            return FrozenDict()
×
UNCOV
47
        return FrozenDict(
1✔
48
            {
49
                script_type: os.path.join(self.address.spec_path, script_src)
50
                for script_type, script_src in value.items()
51
            }
52
        )
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

© 2025 Coveralls, Inc