summaryrefslogtreecommitdiffstats
path: root/Doc/library/enum.rst
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-120361: Add `nonmember` test with enum flags inside to `test_enum` ↵Miss Islington (bot)2024-06-141-1/+1
| | | | | | | | | | (GH-120364) (#120511) gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (GH-120364) * gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (cherry picked from commit 7fadfd82ebf6ea90b38cb3f2a046a51f8601a205) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.13] docs: module page titles should not start with a link to themselves ↵Miss Islington (bot)2024-05-081-2/+2
| | | | | | | | (GH-117099) (#118790) docs: module page titles should not start with a link to themselves (GH-117099) (cherry picked from commit bcb435ee8ff41b5ec5d879ee0b6651f146a66151) Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
* gh-118650: Document `Enum._repr_*` reservation exclusion (GH-118698)chrysn2024-05-071-1/+7
|
* gh-118310: Fix documentation for `enum.Enum.__new__` (GH-118311)Momo Eissenhauer2024-05-071-5/+7
| | | | | | | The provided example was incorrect: - The example enum was missing the `int` mixin as implied by the context - The value of `int('1a', 16)` was incorrectly given as 17 (should be 26)
* Fix note in Enum.__new__ docs (#118284)Philipp A2024-04-261-5/+5
|
* gh-105535 Document potential performance trap during enum creation (GH-107119)Nicolas A. Oyarzabal2024-03-081-0/+7
| | | | Co-authored-by: Ethan Furman <ethan@stoneleaf.us> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-116281: Remove wrong '\' from '\*' in some doc signatures (#116282)HarryLHW2024-03-031-4/+4
|
* gh-115821: [Enum] better error message for calling super().__new__() (GH-116063)Ethan Furman2024-02-281-0/+3
| | | | docs now state to not call super().__new__ if super().__new__ is called, a better error message is now used
* gh-101100: Fix sphinx warnings in `library/enum.rst` (#114696)Nikita Sobolev2024-02-091-2/+15
| | | | Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-115106 docs: 'enum.Flag.__iter__()' did not exist prior to Python 3.11 ↵Finite State Machine2024-02-071-3/+1
| | | | | (GH-115107) change versionchanged to versionadded
* gh-114071: [Enum] update docs and code for tuples/subclasses (GH-114871)Ethan Furman2024-02-041-3/+26
| | | | | | | | | | | | | | | | | | | | | | | 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.
* gh-114231: Fix indentation in enum.rst (#114232)Miyashita Yosuke2024-01-181-1/+1
|
* gh-112328: [Enum] Make some private attributes public. (GH-112514)Ethan Furman2023-12-051-21/+39
| | | | | | | | | | | | | * [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>
* gh-110679: Improved markup in enum.rst (GH-110747)Khalil Mouawad2023-10-251-15/+15
|
* GH-111182: Update EnumType.__contains__ docs (GH-111184)InSync2023-10-241-3/+4
|
* Remove unnecessary escape in Doc/library/enum.rst (GH-110780)InSync2023-10-121-1/+1
|
* gh-110631: Fix reST indentation in `Doc/library` (#110685)Ezio Melotti2023-10-111-14/+14
| | | Fix wrong indentation in the Doc/library dir.
* gh-107700: [Enum] Document that `EnumType` was added in 3.11 (GH-108260)Nikita Sobolev2023-08-221-0/+4
|
* gh-104659: Consolidate python examples in enum documentation (#104665)Thomas Hisch2023-05-191-6/+6
|
* gh-103596: [Enum] do not shadow mixed-in methods/attributes (GH-103600)Ethan Furman2023-04-181-3/+4
| | | | | | | | | | | | | | | | | | 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-103365: [Enum] STRICT boundary corrections (GH-103494)Ethan Furman2023-04-131-2/+3
| | | | | | STRICT boundary: - fix bitwise operations - make default for Flag
* gh-98298, gh-74730: [Enum] update docs (GH-103163)Ethan Furman2023-04-031-26/+25
| | | | fix FlagBoundary statements add warning about reloading modules and enum identity
* gh-101739: [Enum] update docs - default boundary for Flag is CONFORM (GH-101746)Owain Davies2023-02-171-9/+8
|
* docs: Fix enum reassign `str` documentation (GH-101507)Peter Gessler2023-02-021-2/+2
|
* gh-101100: [Enum] Fix sphinx warnings in docs (GH-101122)Nikita Sobolev2023-01-201-12/+12
| | | | | * gh-101100: [Enum] Fix sphinx warnings in Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* Fix typo in `ReprEnum` documentation (#101079)Viicos2023-01-171-1/+1
|
* Fix typo in `enum` module documentation (#100992)Noam Cohen2023-01-121-1/+1
|
* [Enum] docs: replace 'last value' by 'highest value' for Flag auto (GH-100709)Christophe Nanteuil2023-01-031-3/+3
|
* gh-100174: [Enum] Correct PowersOfThree example. (GH-100178)Beweeted2022-12-111-2/+2
| | | Changed from multiples of 3 to powers of 3 to match the class name.
* gh-99087: Add missing newline for prompts in docs (GH-98993)Stanley2022-12-091-0/+13
| | | 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/+2
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* gh-93464: [Enum] Add versionchanged tag (#99997)Ethan Furman2022-12-051-0/+5
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* [Enum] Fix typos in the documentation (GH-99960)Géry Ogam2022-12-041-26/+26
|
* gh-99304: [Enum] clarify what constitutes a flag alias (GH-99395)Ethan Furman2022-11-121-12/+27
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* gh-93464: [Enum] fix auto() failure during multiple assignment (GH-99148)Ethan Furman2022-11-061-3/+12
| | | | | | * 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')`
* [Enum docs]: fix order of arguments to isinstance() (#98542)Clément Robert2022-10-221-1/+1
|
* gh-98298: [Enum] document ReprEnum, global_enum, and show_flag_values (GH-98455)Ethan Furman2022-10-211-1/+47
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* GH-95172 Make the same version `versionadded` oneline (#95172)1809092022-10-051-2/+1
| | | | | | | | | | | * Make the same version versionadded oneline * Format versionadded for enum.rst * Format versionadded A single line versionadded was reading better. Co-authored-by: Senthil Kumaran <senthil@python.org>
* gh-95077: [Enum] add code-based deprecation warnings for member.member ↵Ethan Furman2022-07-251-7/+0
| | | | | | | access (GH-95083) * issue deprecation warning for member.member access * always store member property in current class * remove __getattr__
* gh-91456: [Enum] Deprecate default auto() behavior with mixed value types ↵Oscar R2022-06-231-0/+4
| | | | | | | (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>
* Restore default role check in `make check`. (#92290)Ezio Melotti2022-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * Restore default role check in `make check`. * Options first, then files. * Update `make.bat` too. * Add a comment explaining the extra options. * No reason to ignore the README.rst. * Enable default-role check in sphinx-lint. Co-authored-by: Julien Palard <julien@palard.fr> * Update sphinx-lint default-role check. * Fix use of the default role in the docs. * Update make.bat to check for the default role too. * Fix comment in make.bat. Co-authored-by: Julien Palard <julien@palard.fr>
* Enum docs: Remove unnecessary apostrophes (#92382)Alex Waygood2022-05-061-2/+2
| | | Replace "it's" with "its".
* gh-78157: [Enum] nested classes will not be members in 3.13 (GH-92366)Ethan Furman2022-05-061-0/+21
| | | | | | | - add member() and nonmember() functions - add deprecation warning for internal classes in enums not becoming members in 3.13 Co-authored-by: edwardcwang
* bpo-46586: Fix documentation links (GH-31216)Meer Suri2022-02-121-1/+1
| | | * Fix enum.property documentation link
* bpo-46569: [Enum] fix typo in `StrEnum` docs (GH-31007)Nikita Sobolev2022-02-031-1/+1
|
* bpo-40066: [Enum] skip failing doc test (GH-30637)Kumar Aditya2022-01-171-92/+173
|
* Revert "bpo-40066: [Enum] update str() and format() output (GH-30582)" ↵Victor Stinner2022-01-171-173/+92
| | | | | (GH-30632) This reverts commit acf7403f9baea3ae1119fc6b4a3298522188bf96.
* bpo-40066: [Enum] update str() and format() output (GH-30582)Ethan Furman2022-01-161-92/+173
| | | | | | | | | | | | | | | 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-46157: fix typo in docs (GH-30237)Kumar Aditya2021-12-231-1/+1
|
* bpo-45535: Improve output of Enum ``dir()`` (GH-29316)Alex Waygood2021-12-021-2/+3
| | | | | | 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.