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

pantsbuild / pants / 24462481292

15 Apr 2026 03:13PM UTC coverage: 89.757% (-3.2%) from 92.924%
24462481292

push

github

web-flow
update the default Pex version to v2.92.2 (#23260)

Release Notes:
 * https://github.com/pex-tool/pex/releases/tag/v2.92.2

3 of 3 new or added lines in 1 file covered. (100.0%)

2567 existing lines in 128 files now uncovered.

82405 of 91809 relevant lines covered (89.76%)

3.6 hits per line

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

60.71
/src/python/pants/init/import_util.py
1
# Copyright 2025 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 importlib.metadata
10✔
7
from collections.abc import Generator
10✔
8
from importlib.metadata import Distribution
10✔
9

10
from packaging.requirements import Requirement
10✔
11
from packaging.utils import NormalizedName, canonicalize_name
10✔
12
from packaging.version import InvalidVersion, Version
10✔
13

14

15
def distribution_matches_requirement(dist: Distribution, requirement: Requirement) -> bool:
10✔
16
    # Check whether the normalized names match.
UNCOV
17
    dist_name = canonicalize_name(dist.name)
×
UNCOV
18
    req_name = canonicalize_name(requirement.name)
×
UNCOV
19
    if dist_name != req_name:
×
UNCOV
20
        return False
×
21

22
    # If there is no version specifier, a name match is sufficient.
UNCOV
23
    if not requirement.specifier:
×
UNCOV
24
        return True
×
25

26
    # Otherwise, check version specifier and see if version is contained.
UNCOV
27
    try:
×
UNCOV
28
        dist_version = Version(dist.version)
×
UNCOV
29
        return requirement.specifier.contains(dist_version)
×
30
    except InvalidVersion:
×
31
        # If we can't parse the version, assume it doesn't match
32
        return False
×
33

34

35
def find_matching_distributions(
10✔
36
    requirement: Requirement | None,
37
) -> Generator[Distribution]:
38
    """Yield distributions matching the given requirement or all active distributions if
39
    `requirement` is `None`."""
40
    seen_dist_names: set[NormalizedName] = set()
2✔
41
    for dist in importlib.metadata.distributions():
2✔
42
        # Skip non-active distributions. Python prefers the first distribution on `sys.path`.
43
        normalized_dist_name = canonicalize_name(dist.name)
2✔
44
        if normalized_dist_name in seen_dist_names:
2✔
45
            continue
2✔
46
        seen_dist_names.add(normalized_dist_name)
2✔
47
        if requirement is None or distribution_matches_requirement(dist, requirement):
2✔
48
            yield dist
2✔
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