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

pantsbuild / pants / 23173035367

17 Mar 2026 12:47AM UTC coverage: 91.371% (-1.6%) from 92.933%
23173035367

push

github

web-flow
update helm (and friends) to a recent 3.x seies (#23143)

v4 is a major breaking change, so holding off on that. (There was also
just a 3.20, but 3.19 has this reassuring series of bug fixes and was
also quite recent.)

2 of 2 new or added lines in 2 files covered. (100.0%)

1263 existing lines in 73 files now uncovered.

86196 of 94336 relevant lines covered (91.37%)

3.87 hits per line

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

88.24
/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
11✔
5
from enum import Enum
11✔
6
from typing import TypeVar
11✔
7

8

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

12

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

16

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

20

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

24

25
def match(enum_instance: _E, enum_values_to_results: Mapping[_E, _V]) -> _V:
11✔
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))
11✔
29
    unrecognized_values = [value for value in enum_values_to_results if value not in all_instances]
11✔
30
    missing_values = [value for value in all_instances if value not in enum_values_to_results]
11✔
31
    if unrecognized_values:
11✔
UNCOV
32
        raise UnrecognizedMatchError(
×
33
            f"Match includes values not defined in the enum. Unrecognized: {unrecognized_values}"
34
        )
35
    if missing_values:
11✔
UNCOV
36
        raise InexhaustiveMatchError(
×
37
            f"All enum values must be covered by the match. Missing: {missing_values}"
38
        )
39
    return enum_values_to_results[enum_instance]
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