| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
| |
|
|
|
|
| |
(GH-109789)
|
|
|
|
|
|
|
| |
add guard so that ``Enum('bar')`` raises a TypeError instead of
creating a new enum class called `bar`. To create the new but
empty class, use:
huh = Enum('bar', names=())
|
|
|
|
|
|
|
|
|
|
|
| |
__new__ (GH-108704)
When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. .
member = object.__new__(cls)
member = int.__new__(cls, value)
member = str.__new__(cls, value)
Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
For example:
class Flag(enum.Flag):
A = 0x01
B = 0x02
MASK = 0xff
~Flag.MASK is Flag(0)
|
|
|
| |
When inverting a Flag member (or boundary STRICT), only consider other canonical flags; when inverting an IntFlag member (or boundary KEEP), also consider aliases.
|
|
|
|
|
| |
* revert enum pickling from by-name to by-value
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For example:
class Book(StrEnum):
title = auto()
author = auto()
desc = auto()
Book.author.desc is Book.desc
but
Book.author.title() == 'Author'
is commonly expected. Using upper-case member names avoids this confusion and possible performance impacts.
Co-authored-by: samypr100 <3933065+samypr100@users.noreply.github.com>
|
|
|
| |
a mixin must either have a __new__ method, or be a dataclass, to be interpreted as a data-type
|
|
|
|
|
|
| |
STRICT boundary:
- fix bitwise operations
- make default for Flag
|
| |
|
|
|
|
| |
i.e. Color.RED.BLUE is now officially supported.
|
|
|
| |
_gnv_ --> _generate_next_value_
|
|
|
|
| |
fix FlagBoundary statements
add warning about reloading modules and enum identity
|
|
|
|
| |
(GH-103222)
|
|
|
|
| |
(GH-103149)
|
| |
|
|
|
|
| |
(GH-103062)
|
| |
|
|
|
|
| |
(GH-101590)
|
| |
|
|
|
|
|
| |
(GH-99520)
Also updates calls in collections, doctest, enum, and typing modules to use _getframemodulename first when available.
|
|
|
|
|
| |
Callables should be either class- or static-methods.
Enum now uses the classmethod version to greatly improve the help
given for enums and flags.
|
|
|
|
|
|
| |
When checking for auto() instances, only top-level usage is supported,
which means either alone or as part of a regular tuple. Other
containers, such as lists, dicts, or namedtuples, will not have auto()
transformed into a value.
|
|
|
| |
Closes #92120
|
|
|
| |
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
|
|
|
|
|
|
|
| |
* use final status to determine lookup or create
* 📜🤖 Added by blurb_it.
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
| |
[Enum] fix negative number infinite loop
- _iter_bits_lsb() now raises a ValueError if a negative number
is passed in
- verify() now skips checking negative numbers for named flags
|
|
|
|
|
|
| |
* fix auto() failure during multiple assignment
i.e. `ONE = auto(), 'text'` will now have `ONE' with the value of `(1,
'text')`. Before it would have been `(<an auto instance>, 'text')`
|
| |
|
| |
|
|
|
|
| |
status category (GH-95453)
|
|
|
|
|
|
|
| |
access (GH-95083)
* issue deprecation warning for member.member access
* always store member property in current class
* remove __getattr__
|
|
|
|
|
| |
performance boost (GH-94913)" (#94985)
This reverts commit c20186c3972ff38577c4c5e32ca86748210983d2.
|
| |
|
|
|
|
| |
boost (GH-94913)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This removes the performance regression in 3.11, **at the expense of not fixing
the "bug" that allows accessing values from values** (e.g. `Color.RED.BLUE`).
Using the benchmark @markshannon [presented](https://github.com/python/cpython/issues/93910#issuecomment-1165503032), the results are:
| Version | Enum | Fast enum | Normal class |
| --- | --- | --- | --- |
| 3.10 | 2.04 | 0.59 | 0.56 |
| 3.11 | 2.78 | 0.31 | 0.15 |
| This PR | 1.30 | 0.32 | 0.16 |
I share this mostly as information about the source of the regression, as this may be useful. It may be that the lower-risk approach for the beta is just to revert to a previously-known working state.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
(GH-91457)
When used with plain Enum, auto() returns the last numeric value assigned, skipping any incompatible member values (such as strings); starting in 3.13 the default auto() for plain Enums will require all the values to be of compatible types, and will return a new value that is 1 higher than any existing value.
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
|
|
| |
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
| |
|
|
|
|
|
|
|
|
| |
GH-26658 introduced a regression in copy / pickle protocol for combined
`enum.Flag`s. `copy.copy(re.A | re.I)` would fail with
`AttributeError: ASCII|IGNORECASE`.
`enum.Flag` now has a `__reduce_ex__()` method that reduces flags by
combined value, not by combined name.
|
|
|
|
|
| |
(GH-93302)
In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type. This change restores that behavior.
|
|
|
| |
`EnumType` attempts to create a custom docstring for each enum/flag, but that was failing with pathological flags that had no members (only multi-bit aliases).
|