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

pantsbuild / pants / 19549135539

20 Nov 2025 07:36PM UTC coverage: 78.566% (-1.7%) from 80.302%
19549135539

Pull #22901

github

web-flow
Merge 9e21d48a2 into 730539e91
Pull Request #22901: Support large numbers of input files to Pyright.

11 of 24 new or added lines in 2 files covered. (45.83%)

1039 existing lines in 59 files now uncovered.

73994 of 94181 relevant lines covered (78.57%)

3.17 hits per line

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

70.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
11✔
5
from pathlib import Path
11✔
6

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

12

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

17

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

21

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

26
    relpath: Path
11✔
27

28

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

33

34
def validate_distdir(distdir: Path, buildroot: Path) -> DistDir:
11✔
UNCOV
35
    if not is_child_of(distdir, buildroot):
×
UNCOV
36
        raise InvalidDistDir(
×
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
×
UNCOV
46
    return DistDir(relpath)
×
47

48

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