| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
| |
(GH-136842)
gh-136764: improve comment in enum.verify.__call__ (GH-136774)
(cherry picked from commit 6a1c93af806d0ca5d3fb86cd183d00013bbf28d1)
Co-authored-by: Saurav Singh <sauravsinghshakya@yahoo.com>
|
| |
|
|
|
|
|
|
|
| |
(GH-132790) (GH-132896)
gh-132684: [Enum] only call _missing_ in __contains__ for Flags (GH-132790)
(cherry picked from commit 22bc953aa9be3039629dd1315f856d2522619412)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-131053) (#131167)
gh-131045: [Enum] fix flag containment checks when using values (GH-131053)
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.
(cherry picked from commit 17d06aeb5476099bc1acd89cd6f69e239e0f9350)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
|
| |
|
|
|
|
| |
(GH-123669) (GH-128142)
Co-authored-by: Petr Viktorin <pviktori@redhat.com>
|
| |
|
|
|
|
|
|
| |
(GH-125858)
gh-125259: Fix error notes removal in enum initialization (GH-125647)
(cherry picked from commit 34653bba644aa5481613f398153757d7357e39ea)
Co-authored-by: Mario Šaško <mariosasko777@gmail.com>
|
| |
|
|
|
|
|
|
| |
values (GH-125735) (GH-125851)
gh-125710: [Enum] fix hashable<->nonhashable comparisons for member values (GH-125735)
(cherry picked from commit aaed91cabcedc16c089c4b1c9abb1114659a83d3)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
| |
|
|
|
| |
A FutureWarning with suggestion to use enum.member() is now emitted
when the partial instance is used as an enum member.
|
| |
|
|
|
|
|
| |
Fix typos (#123775)
(cherry picked from commit 9017b95ff2dcff16bcb0b0a609ed2b0daa845943)
Co-authored-by: algonell <algonell@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)
|
| | |
|
| |
|
|
| |
(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
|