python / python/cpython

Add a "warning" option to enum.FlagBoundary

Open
#99,999 1 comment 0 reactions 1 assignee View on GitHub

@ethanfurman is already working on this.

Since Dec 5, 2022.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

The new enum.FlagBoundary system seems quite nice, but there does not appear to be an option to accept a value (a.k.a KEEP) but warn when out of range (STRICT throws an error, and would require a second class to wrap the value).

Pitch

I see two possible options:

  1. Add a new flag (e.g. WARN or WARN_KEEP) which warns when the value is out of range
  2. Modify KEEP such that a warning is displayed when the value is out of range

(1) seems like the better option from a backwards-compatibility perspective, but (2) seems like the better option from a usability and maintenance perspective (as missing values are easier to spot).

Previous discussion

None

Linked PRs
  • gh-154501

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.