Commit graph

148 commits

Author SHA1 Message Date
Miss Islington (bot)
9f153a2acf
[3.12] gh-123005: Add version added in enum.Flag.__len__ (GH-123007) (#123025)
gh-123005: Add version added in enum.Flag.__len__ (GH-123007)
(cherry picked from commit 8e2dc7f380)

Co-authored-by: Damien <81557462+Damien-Chen@users.noreply.github.com>
2024-08-14 22:30:44 +01:00
Miss Islington (bot)
d2105a1eab
[3.12] gh-120361: Add nonmember test with enum flags inside to test_enum (GH-120364) (#120512)
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 7fadfd82eb)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-06-14 20:59:12 +03:00
Miss Islington (bot)
b83b3cb9da
[3.12] docs: module page titles should not start with a link to themselves (GH-117099) (#118791)
docs: module page titles should not start with a link to themselves (GH-117099)
(cherry picked from commit bcb435ee8f)

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2024-05-08 19:42:01 +00:00
Miss Islington (bot)
8e53f66797
[3.12] gh-118310: Fix documentation for enum.Enum.__new__ (GH-118311) (GH-118699)
gh-118310: Fix documentation for `enum.Enum.__new__` (GH-118311)

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)
(cherry picked from commit 48e52fe2c9)

Co-authored-by: Momo Eissenhauer <mmEissen@users.noreply.github.com>
2024-05-07 14:02:55 +02:00
Jelle Zijlstra
186fbe82f7
[3.12] Fix note in Enum.__new__ docs (GH-118284) (#118325)
(cherry picked from commit 5a4d3df2fa)

Co-authored-by: Philipp A <flying-sheep@web.de>
2024-04-26 16:25:31 -07:00
Miss Islington (bot)
d5d86e2145
[3.12] gh-105535 Document potential performance trap during enum creation (GH-107119) (GH116511)
(cherry picked from commit 601f3a7b33)

Co-authored-by: Nicolas A. Oyarzabal <79150521+nicky-eng@users.noreply.github.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-03-08 16:56:58 -08:00
Miss Islington (bot)
e95e837541
[3.12] gh-116281: Remove wrong '\' from '\*' in some doc signatures (GH-116282) (#116285)
gh-116281: Remove wrong '\' from '\*' in some doc signatures (GH-116282)
(cherry picked from commit 4859ecb860)

Co-authored-by: HarryLHW <123lhw321@gmail.com>
2024-03-03 14:42:22 -05:00
Ethan Furman
83ff92d225
[3.12] gh-115821: [Enum] better error message for calling super().__new__() (GH-116065)
Add note to not call super().__new__() in docs.
2024-02-28 15:17:20 -08:00
Nikita Sobolev
3539b02873
[3.12] gh-101100: Fix sphinx warnings in library/enum.rst (GH-114696) (GH-115208) 2024-02-09 12:10:26 -08:00
Miss Islington (bot)
108ff59c8f
[3.12] gh-115106 docs: 'enum.Flag.__iter__()' did not exist prior to Python 3.11 (GH-115107) (GH-115117)
change versionchanged to versionadded
(cherry picked from commit 3f71c416c0)

Co-authored-by: Finite State Machine <38001514+finite-state-machine@users.noreply.github.com>
2024-02-08 14:03:12 -08:00
Miss Islington (bot)
7d2f88edf0
[3.12] gh-114071: [Enum] update docs and code for tuples/subclasses (GH-114871) (GH-114993)
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))
    GH- 4 5 6

it made sense to also support tuple subclasses in enum definitions.
(cherry picked from commit ff7588b729)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2024-02-08 14:01:38 -08:00
Miss Islington (bot)
55b73a5c78
[3.12] gh-114231: Fix indentation in enum.rst (GH-114232) (#114234)
Co-authored-by: Miyashita Yosuke <44266492+miyashiiii@users.noreply.github.com>
2024-01-18 09:29:34 +00:00
Miss Islington (bot)
2a28aa10a8
[3.12] GH-111182: Update EnumType.__contains__ docs (GH-111184) (GH-111281)
GH-111182: Update EnumType.__contains__ docs (GH-111184)
(cherry picked from commit c0ea67dd0d)

Co-authored-by: InSync <122007197+InSyncWithFoo@users.noreply.github.com>
2023-10-24 10:52:17 -07:00
Miss Islington (bot)
cae968ba17
[3.12] gh-110631: Fix reST indentation in Doc/library (GH-110685) (#110736)
gh-110631: Fix reST indentation in `Doc/library` (GH-110685)

Fix wrong indentation in the Doc/library dir.
(cherry picked from commit bb7923f556)

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2023-10-11 23:11:28 +02:00
Miss Islington (bot)
1dbf11814f
[3.12] gh-107700: [Enum] Document that EnumType was added in 3.11 (GH-108260) (#108301)
(cherry picked from commit e8ef0bdd8c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-08-22 20:34:56 +02:00
Thomas Hisch
3ac856e697
gh-104659: Consolidate python examples in enum documentation (#104665) 2023-05-19 11:46:20 -06:00
Ethan Furman
700ec657c8
gh-103596: [Enum] do not shadow mixed-in methods/attributes (GH-103600)
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>
2023-04-18 16:19:23 -07:00
Ethan Furman
2194071540
gh-103365: [Enum] STRICT boundary corrections (GH-103494)
STRICT boundary:

- fix bitwise operations
- make default for Flag
2023-04-13 08:24:33 -07:00
Ethan Furman
5ffc1e5a21
gh-98298, gh-74730: [Enum] update docs (GH-103163)
fix FlagBoundary statements
add warning about reloading modules and enum identity
2023-04-03 14:57:42 -07:00
Owain Davies
7f1c721756
gh-101739: [Enum] update docs - default boundary for Flag is CONFORM (GH-101746) 2023-02-17 13:36:47 -08:00
Peter Gessler
24cbc7a2a0
docs: Fix enum reassign str documentation (GH-101507) 2023-02-02 12:12:57 -08:00
Nikita Sobolev
9e025d305f
gh-101100: [Enum] Fix sphinx warnings in docs (GH-101122)
* gh-101100: [Enum] Fix sphinx warnings in 

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2023-01-19 18:16:21 -08:00
Viicos
c5660ae96f
Fix typo in ReprEnum documentation (#101079) 2023-01-17 16:21:56 +05:30
Noam Cohen
2161bbf243
Fix typo in enum module documentation (#100992) 2023-01-12 21:10:29 +05:30
Christophe Nanteuil
64ed609c53
[Enum] docs: replace 'last value' by 'highest value' for Flag auto (GH-100709) 2023-01-03 14:08:50 -08:00
Beweeted
868bab0fdc
gh-100174: [Enum] Correct PowersOfThree example. (GH-100178)
Changed from multiples of 3 to powers of 3 to match the class name.
2022-12-11 15:20:59 -08:00
Stanley
286e3c76a9
gh-99087: Add missing newline for prompts in docs (GH-98993)
Add newline for prompts so copying to REPL does not cause errors.
2022-12-08 19:31:19 -08:00
Ethan Furman
679efbb080
gh-94943: [Enum] improve repr() when inheriting from a dataclass (GH-99740)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-12-06 13:43:41 -08:00
Ethan Furman
e3a3863cb9
gh-93464: [Enum] Add versionchanged tag (#99997)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-12-05 12:35:31 +02:00
Géry Ogam
2ae894b6d1
[Enum] Fix typos in the documentation (GH-99960) 2022-12-04 11:49:31 -08:00
Ethan Furman
73a921b070
gh-99304: [Enum] clarify what constitutes a flag alias (GH-99395)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-11-12 10:39:47 -08:00
Ethan Furman
8feb7ab77c
gh-93464: [Enum] fix auto() failure during multiple assignment (GH-99148)
* 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')`
2022-11-05 18:01:08 -07:00
Clément Robert
327fc1c6fa
[Enum docs]: fix order of arguments to isinstance() (#98542) 2022-10-22 12:29:00 +01:00
Ethan Furman
3e95ffc7ae
gh-98298: [Enum] document ReprEnum, global_enum, and show_flag_values (GH-98455)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-10-21 15:36:41 -07:00
180909
d6062d1170
GH-95172 Make the same version versionadded oneline (#95172)
* 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>
2022-10-05 10:52:59 -07:00
Ethan Furman
4e704d7847
gh-95077: [Enum] add code-based deprecation warnings for member.member access (GH-95083)
* issue deprecation warning for member.member access
* always store member property in current class
* remove __getattr__
2022-07-25 11:05:10 -07:00
Oscar R
fb1e9506c1
gh-91456: [Enum] Deprecate default auto() behavior with mixed value types (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>
2022-06-22 23:20:24 -07:00
Ezio Melotti
953ab07952
Restore default role check in make check. (#92290)
* 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>
2022-05-15 17:34:52 +02:00
Alex Waygood
291945bc6e
Enum docs: Remove unnecessary apostrophes (#92382)
Replace "it's" with "its".
2022-05-06 11:53:00 +02:00
Ethan Furman
93364f9716
gh-78157: [Enum] nested classes will not be members in 3.13 (GH-92366)
- add member() and nonmember() functions
- add deprecation warning for internal classes in enums not
  becoming members in 3.13

Co-authored-by: edwardcwang
2022-05-06 00:16:22 -07:00
Meer Suri
9d9cfd61ec
bpo-46586: Fix documentation links (GH-31216)
* Fix enum.property documentation link
2022-02-11 20:21:38 -08:00
Nikita Sobolev
734b1f119b
bpo-46569: [Enum] fix typo in StrEnum docs (GH-31007) 2022-02-03 07:22:41 -08:00
Kumar Aditya
83d544b929
bpo-40066: [Enum] skip failing doc test (GH-30637) 2022-01-17 07:18:13 -08:00
Victor Stinner
42a64c03ec
Revert "bpo-40066: [Enum] update str() and format() output (GH-30582)" (GH-30632)
This reverts commit acf7403f9b.
2022-01-17 13:58:40 +01:00
Ethan Furman
acf7403f9b
bpo-40066: [Enum] update str() and format() output (GH-30582)
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`
2022-01-15 22:41:43 -08:00
Kumar Aditya
71ef0b4c2b
bpo-46157: fix typo in docs (GH-30237) 2021-12-23 11:17:31 +02:00
Alex Waygood
b2afdc95cc
bpo-45535: Improve output of Enum `dir()` (GH-29316)
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.
2021-12-02 08:49:52 -08:00
Ethan Furman
cb755dba7a
bpo-45740: [Enum] add versionadded markers to docs (GH-29443)
[Enum] add versionadded markers to docs
2021-11-06 10:16:43 -07:00
Christian Clauss
241bda785a
[doc] Fix typos found using codespell (GH-28744)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-10-05 23:48:44 +02:00
Steffen Zeile
2f54fbafa6
bpo-44559: [Enum] correct versionadded to 3.11 for new features (GH-27388) 2021-07-27 08:20:00 -07:00