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

pantsbuild / pants / 21552830208

31 Jan 2026 11:40PM UTC coverage: 80.277% (-0.05%) from 80.324%
21552830208

Pull #23062

github

web-flow
Merge 808a9786c into 2c4dcf9cf
Pull Request #23062: Remove support for Get

18 of 25 new or added lines in 4 files covered. (72.0%)

17119 existing lines in 541 files now uncovered.

78278 of 97510 relevant lines covered (80.28%)

3.36 hits per line

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

95.83
/src/python/pants/core/util_rules/distdir.py
1
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from dataclasses import dataclass
12✔
5
from pathlib import Path
12✔
6

7
from pants.base.build_root import BuildRoot
12✔
8
from pants.engine.rules import collect_rules, rule
12✔
9
from pants.option.global_options import GlobalOptions
12✔
10
from pants.util.strutil import softwrap
12✔
11

12

13
def is_child_of(path: Path, directory: Path) -> bool:
12✔
UNCOV
14
    abs_path = path if path.is_absolute() else directory.joinpath(path).resolve()
1✔
UNCOV
15
    return directory == abs_path or directory in abs_path.parents
1✔
16

17

18
class InvalidDistDir(Exception):
12✔
19
    pass
12✔
20

21

22
@dataclass(frozen=True)
12✔
23
class DistDir:
12✔
24
    """The directory to which we write distributable files."""
25

26
    relpath: Path
12✔
27

28

29
@rule
12✔
30
async def get_distdir(global_options: GlobalOptions, buildroot: BuildRoot) -> DistDir:
12✔
31
    return validate_distdir(Path(global_options.pants_distdir), buildroot.pathlib_path)
×
32

33

34
def validate_distdir(distdir: Path, buildroot: Path) -> DistDir:
12✔
UNCOV
35
    if not is_child_of(distdir, buildroot):
1✔
UNCOV
36
        raise InvalidDistDir(
1✔
37
            softwrap(
38
                f"""
39
            When set to an absolute path, `--pants-distdir` must be relative to the build root.
40
            You set it to {distdir}. Instead, use a relative path or an absolute path relative
41
            to the build root.
42
            """
43
            )
44
        )
UNCOV
45
    relpath = distdir.relative_to(buildroot) if distdir.is_absolute() else distdir
1✔
UNCOV
46
    return DistDir(relpath)
1✔
47

48

49
def rules():
12✔
50
    return collect_rules()
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