| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
| |
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
|
| | |
|
| |
|
| |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
| |
|
| |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix flag mask inversion when unnamed flags exist.
For example:
class Flag(enum.Flag):
A = 0x01
B = 0x02
MASK = 0xff
~Flag.MASK is Flag(0)
* EJECT and KEEP flags (IntEnum is KEEP) use direct value.
* correct Flag inversion to only flip flag bits
IntFlag will flip all bits -- this only makes a difference in flag sets with
missing values.
* correct negative assigned values in flags
negative values are no longer used as-is, but become inverted; i.e.
class Y(self.enum_type):
A = auto()
B = auto()
C = ~A # aka ~1 aka 0b1 110 (from enum.bin()) aka 6
D = auto()
assert Y.C. is Y.B|Y.D
|
| |
|
| |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
| | |
|
| |
|
|
|
|
|
| |
Check would fail if value would create a pseudo-member, but that member
had not yet been created. We now attempt to create a pseudo-member for
a passed-in value first.
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
|
| |
|
|
|
| |
Co-authored-by: Rafi <rafi.promit@gmail.com>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
| |
|
|
|
| |
remove unnecessary __init__ method from Enum
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
| | |
|
| |
|
|
| |
(GH-125735)
|
| |
|
| |
This is an alternative to GH-100168.
|
| | |
|
| |
|
| |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
| |
|
|
| |
(GH-118651)
|
| |
|
|
| |
It is set by compiler with the line number of the first line of
the class definition.
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
* and fix global flag repr
* Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
|
| |
|
| |
* and fix _not_given usage
|
| |
|
|
| |
Cardinal(1, 0) (GH-116072)
|
| |
|
|
| |
docs now state to not call super().__new__
if super().__new__ is called, a better error message is now used
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Update documentation with `__new__` and `__init__` entries.
Support use of `auto()` in tuple subclasses on member assignment lines. Previously, auto() was only supported on the member definition line either solo or as part of a tuple:
RED = auto()
BLUE = auto(), 'azul'
However, since Python itself supports using tuple subclasses where tuples are expected, e.g.:
from collections import namedtuple
T = namedtuple('T', 'first second third')
def test(one, two, three):
print(one, two, three)
test(*T(4, 5, 6))
# 4 5 6
it made sense to also support tuple subclasses in enum definitions.
|
| |
|
| |
This reverts commit 05e142b1543eb9662d6cc33722e7e16250c9219f.
|
| |
|
|
| |
(GH-114160)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* [Enum] Make some private attributes public.
- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``
---------
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
| | |
|
| |
|
| |
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)
|
| | |
|