summaryrefslogtreecommitdiffstats
path: root/Doc/howto/enum.rst
Commit message (Collapse)AuthorAgeFilesLines
* gh-114803: Mention that `@dataclass` should not be applied on enums (GH-114891)Nikita Sobolev2024-02-031-1/+18
| | | | Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-112328: [Enum] Make some private attributes public. (GH-112514)Ethan Furman2023-12-051-20/+47
| | | | | | | | | | | | | * [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>
* [Enum] update class creation for RuntimeError changes (GH-111815)Ethan Furman2023-11-291-1/+0
|
* gh-111895: Convert definition list to bullet list for readability on mobile ↵Hugo van Kemenade2023-11-091-6/+6
| | | | | (#111898) Convert definition list to bullet list for readability on mobile
* gh-111181: Fix enum doctests (GH-111180)Nikita Sobolev2023-10-301-3/+6
| | | Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-110631: Fix reST indentation (#110724)Ezio Melotti2023-10-111-7/+8
| | | | | * Fix wrong indentation in the other dirs. * Fix more wrong indentation.
* gh-108682: [Enum] raise TypeError if super().__new__ called in custom ↵Ethan Furman2023-08-311-1/+22
| | | | | | | | | | | __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.
* gh-105332: [Enum] Fix unpickling flags in edge-cases (GH-105348)Nikita Sobolev2023-06-081-1/+10
| | | | | * revert enum pickling from by-name to by-value Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-103596: [Enum] do not shadow mixed-in methods/attributes (GH-103600)Ethan Furman2023-04-181-3/+11
| | | | | | | | | | | | | | | | | | 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>
* gh-103479: [Enum] require __new__ to be considered a data type (GH-103495)Ethan Furman2023-04-131-3/+5
| | | a mixin must either have a __new__ method, or be a dataclass, to be interpreted as a data-type
* gh-93910: [Enum] remove member.member deprecation (GH-103236)Ethan Furman2023-04-061-4/+3
| | | | i.e. Color.RED.BLUE is now officially supported.
* gh-103056: [Enum] use staticmethod decorator for _gnv_ (GH-103231)Ethan Furman2023-04-041-0/+1
| | | _gnv_ --> _generate_next_value_
* gh-98298, gh-74730: [Enum] update docs (GH-103163)Ethan Furman2023-04-031-0/+5
| | | | fix FlagBoundary statements add warning about reloading modules and enum identity
* gh-99087: Add missing newline for prompts in docs (GH-98993)Stanley2022-12-091-0/+2
| | | Add newline for prompts so copying to REPL does not cause errors.
* gh-94943: [Enum] improve repr() when inheriting from a dataclass (GH-99740)Ethan Furman2022-12-061-0/+25
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* gh-99304: [Enum] clarify what constitutes a flag alias (GH-99395)Ethan Furman2022-11-121-3/+46
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* [Enum] Typo: fix DuplicateFreeEnum example docs (GH-99265)Bruno Neyra2022-11-091-1/+1
|
* Docs: Fix backtick errors found by sphinx-lint (#97998)Hugo van Kemenade2022-10-071-1/+1
| | | Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* gh-95077: [Enum] add code-based deprecation warnings for member.member ↵Ethan Furman2022-07-251-15/+4
| | | | | | | access (GH-95083) * issue deprecation warning for member.member access * always store member property in current class * remove __getattr__
* [doc]: Spotted errors while working on rstlint. (GH-30879)Julien Palard2022-01-271-2/+1
| | | | Also ignored some `make suspicious` false positives while assuring true positives were properly seen by rstlint.
* bpo-40066: [Enum] skip failing doc test (GH-30637)Kumar Aditya2022-01-171-146/+126
|
* Revert "bpo-40066: [Enum] update str() and format() output (GH-30582)" ↵Victor Stinner2022-01-171-126/+146
| | | | | (GH-30632) This reverts commit acf7403f9baea3ae1119fc6b4a3298522188bf96.
* bpo-40066: [Enum] update str() and format() output (GH-30582)Ethan Furman2022-01-161-146/+126
| | | | | | | | | | | | | | | Undo rejected PEP-663 changes: - restore `repr()` to its 3.10 status - restore `str()` to its 3.10 status New changes: - `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result - zero-valued flags without a name have a slightly changed repr(), e.g. `repr(Color(0)) == '<Color: 0>'` - update `dir()` for mixed-in types to return all the methods and attributes of the mixed-in type - added `_numeric_repr_` to `Flag` to control display of unnamed values - enums without doc strings have a more comprehensive doc string added - `ReprEnum` added -- inheriting from this makes it so only `__repr__` is replaced, not `__str__` nor `__format__`; `IntEnum`, `IntFlag`, and `StrEnum` all inherit from `ReprEnum`
* bpo-45331: [Enum] add rule to docs that mixin type must be subclassable ↵Nikita Sobolev2022-01-101-4/+7
| | | | (GH-30521)
* bpo-45535: Improve output of Enum ``dir()`` (GH-29316)Alex Waygood2021-12-021-3/+4
| | | | | | Modify the ``EnumType.__dir__()`` and ``Enum.__dir__()`` to ensure that user-defined methods and methods inherited from mixin classes always show up in the output of `help()`. This change also makes it easier for IDEs to provide auto-completion.
* bpo-45740: [Enum] add versionadded markers to docs (GH-29443)Ethan Furman2021-11-061-7/+6
| | | [Enum] add versionadded markers to docs
* bpo-44174: [Enum] add reference to name mangling (GH-29116)Ethan Furman2021-10-211-1/+2
|
* Small text fixes for enum.rst (#27322)Elliot Waite2021-07-261-8/+9
| | | Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* Fix error in Enum documentation example code that was referring to the wrong ↵krisaoe2021-05-041-1/+1
| | | | enum. (#25837)
* bpo-40066: Enum: modify `repr()` and `str()` (GH-22392)Ethan Furman2021-03-311-0/+1416
* Enum: streamline repr() and str(); improve docs - repr() is now ``enum_class.member_name`` - stdlib global enums are ``module_name.member_name`` - str() is now ``member_name`` - add HOW-TO section for ``Enum`` - change main documentation to be an API reference