Commit message (Collapse) | Author | Age | Files | Lines | ||
---|---|---|---|---|---|---|
... | ||||||
* | bpo-42901: [Enum] move member creation to `__set_name__` (GH-24196) | Ethan Furman | 2021-01-13 | 1 | -107/+190 | |
| | | | | | | | | | | | `type.__new__` calls `__set_name__` and `__init_subclass__`, which means that any work metaclasses do after calling `super().__new__()` will not be available to those two methods. In particular, `Enum` classes that want to make use of `__init_subclass__` will not see any members. Almost all customization is therefore moved to before the `type.__new__()` call, including changing all members to a proto member descriptor with a `__set_name__` that will do the final conversion of a member to be an instance of the `Enum` class. | |||||
* | bpo-42851: [Enum] remove brittle __init_subclass__ support (GH-24154) | Ethan Furman | 2021-01-07 | 1 | -30/+1 | |
| | | | Solution to support calls to `__init_subclass__` with members defined is too brittle and breaks with certain mixins. | |||||
* | bpo-42727: [Enum] use super() and include **kwds (GH-23927) | Ethan Furman | 2020-12-25 | 1 | -2/+2 | |
| | | | | | | | | for multiple inheritance support: use super().new pass **kwds to super().new | |||||
* | [Enum] EnumMeta.__prepare__ now accepts **kwds (#23917) | Ethan Furman | 2020-12-24 | 1 | -1/+1 | |
| | ||||||
* | bpo-34750: [Enum] add `_EnumDict.update()` support (GH-23725) | Ethan Furman | 2020-12-10 | 1 | -1/+11 | |
| | | | | | | | | | | | | | | | | This allows easier Enum construction in unusual cases, such as including dynamic member definitions into a class definition: # created dynamically foo_defines = {'FOO_CAT': 'aloof', 'BAR_DOG': 'friendly', 'FOO_HORSE': 'big'} class Foo(Enum): vars().update({ k: v for k, v in foo_defines.items() if k.startswith('FOO_') }) def upper(self): # example method return self.value.upper() | |||||
* | bpo-42385: [Enum] add `_generate_next_value_` to StrEnum (GH-23735) | Ethan Furman | 2020-12-10 | 1 | -0/+6 | |
| | | | The default for auto() is to return an integer, which doesn't work for `StrEnum`. The new `_generate_next_value_` for `StrEnum` returns the member name, lower cased. | |||||
* | bpo-42517: [Enum] do not convert private names into members (GH-23722) | Ethan Furman | 2020-12-10 | 1 | -1/+18 | |
| | | | private names, such as `_Color__hue` and `_Color__hue_` are now normal attributes, and do not become members nor raise exceptions | |||||
* | bpo-42567: [Enum] call __init_subclass__ after members are added (GH-23714) | Ethan Furman | 2020-12-10 | 1 | -2/+30 | |
| | | | | | When creating an Enum, type.__new__ calls __init_subclass__, but at that point the members have not been added. This patch suppresses the initial call, then manually calls the ancestor __init_subclass__ before returning the new Enum class. | |||||
* | [Enum] reformat and add doc strings (GH-23705) | Ethan Furman | 2020-12-08 | 1 | -53/+134 | |
| | ||||||
* | bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497) | Ethan Furman | 2020-12-08 | 1 | -1/+1 | |
| | ||||||
* | bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487) | Ethan Furman | 2020-12-07 | 1 | -3/+8 | |
| | ||||||
* | bpo-41816: `StrEnum.__str__` is `str.__str__` (GH-22362) | Ethan Furman | 2020-09-22 | 1 | -0/+2 | |
| | | | use `str.__str__` for `StrEnum` so that `str(StrEnum.member)` is the same as directly accessing the string value of the `StrEnum` member | |||||
* | bpo-41816: add `StrEnum` (GH-22337) | Ethan Furman | 2020-09-22 | 1 | -2/+30 | |
| | | | | `StrEnum` ensures that its members were already strings, or intended to be strings. | |||||
* | bpo-40084: Enum - dir() includes member attributes (GH-19219) | Angelin BOOZ | 2020-09-21 | 1 | -1/+1 | |
| | ||||||
* | Enum: make `Flag` and `IntFlag` members iterable (GH-22221) | Ethan Furman | 2020-09-16 | 1 | -0/+4 | |
| | ||||||
* | _auto_called cleanup (GH-22285) | Ethan Furman | 2020-09-16 | 1 | -1/+1 | |
| | ||||||
* | bpo-39728: Enum: fix duplicate `ValueError` (GH-22277) | Ethan Furman | 2020-09-16 | 1 | -1/+1 | |
| | | | | fix default `_missing_` to return `None` instead of raising a `ValueError` Co-authored-by: Andrey Darascheka <andrei.daraschenka@leverx.com> | |||||
* | bpo-41517: do not allow Enums to be extended (#22271) | Ethan Furman | 2020-09-16 | 1 | -5/+14 | |
| | | | fix bug that let Enums be extended via multiple inheritance | |||||
* | bpo-41789: honor object overrides in Enum classes (GH-22250) | Ethan Furman | 2020-09-15 | 1 | -0/+4 | |
| | | | | | EnumMeta double-checks that `__repr__`, `__str__`, `__format__`, and `__reduce_ex__` are not the same as `object`'s, and replaces them if they are -- even if that replacement was intentionally done in the Enum being constructed. This patch fixes that. Automerge-Triggered-By: @ethanfurman | |||||
* | bpo-39587: Enum - use correct mixed-in data type (GH-22263) | Ethan Furman | 2020-09-15 | 1 | -1/+12 | |
| | ||||||
* | bpo-38967: Improve the error msg for reserved _sunder_ names in enum (GH-18370) | Zackery Spytz | 2020-09-13 | 1 | -1/+2 | |
| | ||||||
* | bpo-40025: Require _generate_next_value_ to be defined before members (GH-19098) | Ethan Onstott | 2020-04-28 | 1 | -0/+5 | |
| | | | require `_generate_next_value_` to be defined before members | |||||
* | bpo-38045: Improve the performance of _decompose() in enum.py (GH-16483) | HongWeipeng | 2019-11-26 | 1 | -23/+10 | |
| | | | | | | * Improve the performance of _decompose() in enum.py Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com> | |||||
* | Remove binding of captured exceptions when not used to reduce the chances of ↵ | Pablo Galindo | 2019-11-19 | 1 | -1/+1 | |
| | | | | | | | creating cycles (GH-17246) Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles. See for example GH-13135 | |||||
* | Doc: Fix spelling errors of 'initial' in enum.py (GH-16314) | HongWeipeng | 2019-09-21 | 1 | -1/+1 | |
| | ||||||
* | bpo-34443: Use __qualname__ instead of __name__ in enum exception messages. ↵ | Walter Dörwald | 2019-07-18 | 1 | -4/+4 | |
| | | | | | (GH-14809) * Use __qualname__ instead of __name__ in enum exception messages. | |||||
* | bpo-37479: on Enum subclasses with mixins, __format__ uses overridden ↵ | thatneat | 2019-07-04 | 1 | -2/+3 | |
| | | | | | __str__ (GH-14545) * bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ | |||||
* | bpo-34282: Remove deprecated enum _convert method (GH-13823) | Zachary Ware | 2019-06-04 | 1 | -6/+0 | |
| | ||||||
* | bpo-35899: Fix Enum handling of empty and weird strings (GH-11891) | Brennan D Baraban | 2019-03-03 | 1 | -8/+9 | |
| | | | | | | | | | | Co-authored-by: Maxwell <maxwellpxt@gmail.com> Co-authored-by: Stéphane Wirtel <stephane@wirtel.be> https://bugs.python.org/issue35899 | |||||
* | bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523) | Rémi Lapeyre | 2019-01-24 | 1 | -1/+1 | |
| | | | https://bugs.python.org/issue17467 | |||||
* | Speed-up building enums by value, e.g. http.HTTPStatus(200) (#11318) | Andrew Svetlov | 2018-12-26 | 1 | -2/+4 | |
| | | | bpo-35585: Speed up enum by-value lookup | |||||
* | bpo-34909: keep searching mixins until base class is found (GH-9737) | Ethan Furman | 2018-10-06 | 1 | -3/+1 | |
| | ||||||
* | bpo-29577: Enum: mixin classes don't mix well with already mixed Enums (GH-9328) | Ethan Furman | 2018-09-22 | 1 | -31/+19 | |
| | | | * bpo-29577: allow multiple mixin classes | |||||
* | bpo-34536: raise error for invalid _missing_ results (GH-9147) | Ethan Furman | 2018-09-12 | 1 | -1/+19 | |
| | | | * raise exception if _missing_ returns None or invalid type | |||||
* | bpo-34282: Fix Enum._convert shadowing members named _convert (GH-8568) | orlnub123 | 2018-09-12 | 1 | -38/+45 | |
| | | | | | * Fix enum members getting shadowed by parent attributes * Move Enum._convert to EnumMeta._convert_ * Deprecate _convert | |||||
* | bpo-33217: Raise TypeError for non-Enum lookups in Enums (GH-6651) | Rahul Jha | 2018-09-10 | 1 | -1/+7 | |
| | | | * bpo-33217: Raise TypeError for non-Enum lookups in Enums | |||||
* | bpo-33866: enum: Stop using OrderedDict (GH-7698) | INADA Naoki | 2018-06-18 | 1 | -13/+5 | |
| | ||||||
* | bpo-31947: remove None default for names param in Enum._create_ (GH-4288) | anentropic | 2018-04-16 | 1 | -1/+1 | |
| | ||||||
* | bpo-31801: Enum: add _ignore_ as class option (#5237) | Ethan Furman | 2018-01-22 | 1 | -1/+19 | |
| | | | | | | | | | | | | | | | | * bpo-31801: Enum: add _ignore_ as class option _ignore_ is a list, or white-space seperated str, of names that will not be candidates for members; these names, and _ignore_ itself, are removed from the final class. * bpo-31801: Enum: add documentation for _ignore_ * bpo-31801: Enum: remove trailing whitespace * bpo-31801: Enum: fix bulleted list format * bpo-31801: add version added for _ignore_ | |||||
* | bpo-30152: Reduce the number of imports for argparse. (#1269) | Serhiy Storchaka | 2017-09-25 | 1 | -7/+4 | |
| | ||||||
* | Spelling fixes (#2902) | Ville Skyttä | 2017-08-03 | 1 | -1/+1 | |
| | ||||||
* | bpo-30616: Functional API of enum allows to create empty enums. (#2304) | Dong-hee Na | 2017-06-21 | 1 | -1/+1 | |
| | | | | | | | | * bpo-30616: Functional API of enum allows to create empty enums. * Update NEWS move addition to avoid conflict | |||||
* | closes issue29167: fix race condition in (Int)Flag | Ethan Furman | 2017-01-24 | 1 | -4/+11 | |
| | ||||||
* | Issue #29103: Remove unused import. Noticed by Jean-Sebastien Bevilacqua. | Raymond Hettinger | 2016-12-30 | 1 | -1/+1 | |
| | ||||||
* | close issue28172: Change all example enum member names to uppercase, per ↵ | Ethan Furman | 2016-11-21 | 1 | -2/+2 | |
| | | | | Guido; patch by Chris Angelico. | |||||
* | issue23591: fix flag decomposition and repr | Ethan Furman | 2016-09-18 | 1 | -58/+94 | |
| | ||||||
* | Enum._convert: sort by value, then by name | Ethan Furman | 2016-09-11 | 1 | -3/+10 | |
| | ||||||
* | issue23591: add auto() for auto-generating Enum member values | Ethan Furman | 2016-09-11 | 1 | -13/+37 | |
| | ||||||
* | issue23591: more docs; slight change to repr | Ethan Furman | 2016-09-04 | 1 | -8/+5 | |
| | ||||||
* | issue23591: bool(empty_flags) == False; more docs & tests | Ethan Furman | 2016-09-02 | 1 | -0/+3 | |
| |