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

pantsbuild / pants / 25443604553

06 May 2026 03:05PM UTC coverage: 92.879% (-0.04%) from 92.915%
25443604553

push

github

web-flow
[pants_ng] Scaffolding for a pants_ng mode. (#23319)

In this mode the command line is parsed as an
NG invocation, and dispatched appropriately.

Of course at the moment there are no
implementations to dispatch to. That will follow.

This does expose a new option, `pants_ng` to users. 
There is a big warning not to set it, but we're not trying
to hide that we're working on a new thing, so I am
comfortable with this.

25 of 76 new or added lines in 9 files covered. (32.89%)

1294 existing lines in 76 files now uncovered.

92234 of 99306 relevant lines covered (92.88%)

4.05 hits per line

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

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

4
from collections.abc import Mapping
12✔
5
from enum import Enum
12✔
6
from typing import TypeVar
12✔
7

8

9
class EnumMatchError(ValueError):
12✔
10
    """Issue when using match() on an enum."""
11

12

13
class InexhaustiveMatchError(EnumMatchError):
12✔
14
    """Not all values of the enum specified in the pattern match."""
15

16

17
class UnrecognizedMatchError(EnumMatchError):
12✔
18
    """A value is used that is not a part of the enum."""
19

20

21
_E = TypeVar("_E", bound=Enum)
12✔
22
_V = TypeVar("_V")
12✔
23

24

25
def match(enum_instance: _E, enum_values_to_results: Mapping[_E, _V]) -> _V:
12✔
26
    # TODO: consider memoizing the result of this entire method, as well as the value of
27
    # `all_instances` for a given enum class!
28
    all_instances: frozenset[_E] = frozenset(type(enum_instance))
12✔
29
    unrecognized_values = [value for value in enum_values_to_results if value not in all_instances]
12✔
30
    missing_values = [value for value in all_instances if value not in enum_values_to_results]
12✔
31
    if unrecognized_values:
12✔
UNCOV
32
        raise UnrecognizedMatchError(
1✔
33
            f"Match includes values not defined in the enum. Unrecognized: {unrecognized_values}"
34
        )
35
    if missing_values:
12✔
UNCOV
36
        raise InexhaustiveMatchError(
1✔
37
            f"All enum values must be covered by the match. Missing: {missing_values}"
38
        )
39
    return enum_values_to_results[enum_instance]
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