Pablo Galindo
c92cd0f3c8
Fix minor typo in the rest format in the enum docs (GH-24335)
2021-01-25 23:23:30 +00:00
Ethan Furman
7aaeb2a3d6
bpo-38250: [Enum] single-bit flags are canonical (GH-24215)
...
Flag members are now divided by one-bit verses multi-bit, with multi-bit being treated as aliases. Iterating over a flag only returns the contained single-bit flags.
Iterating, repr(), and str() show members in definition order.
When constructing combined-member flags, any extra integer values are either discarded (CONFORM), turned into ints (EJECT) or treated as errors (STRICT). Flag classes can specify which of those three behaviors is desired:
>>> class Test(Flag, boundary=CONFORM):
... ONE = 1
... TWO = 2
...
>>> Test(5)
<Test.ONE: 1>
Besides the three above behaviors, there is also KEEP, which should not be used unless necessary -- for example, _convert_ specifies KEEP as there are flag sets in the stdlib that are incomplete and/or inconsistent (e.g. ssl.Options). KEEP will, as the name suggests, keep all bits; however, iterating over a flag with extra bits will only return the canonical flags contained, not the extra bits.
Iteration is now in member definition order. If member definition order
matches increasing value order, then a more efficient method of flag
decomposition is used; otherwise, sort() is called on the results of
that method to get definition order.
``re`` module:
repr() has been modified to support as closely as possible its previous
output; the big difference is that inverted flags cannot be output as
before because the inversion operation now always returns the comparable
positive result; i.e.
re.A|re.I|re.M|re.S is ~(re.L|re.U|re.S|re.T|re.DEBUG)
in both of the above terms, the ``value`` is 282.
re's tests have been updated to reflect the modifications to repr().
2021-01-25 14:26:19 -08:00
Andre Delfino
96a09df644
[doc] Fix a few margins due to bad markup (GH-23619)
2020-12-17 09:25:55 -08:00
Ethan Furman
efb13be72c
bpo-42385: [Enum] add `_generate_next_value_` to StrEnum (GH-23735)
...
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.
2020-12-10 12:20:06 -08:00
Ethan Furman
7cf0aad96d
bpo-42517: [Enum] do not convert private names into members (GH-23722)
...
private names, such as `_Color__hue` and `_Color__hue_` are now normal attributes, and do not become members nor raise exceptions
2020-12-09 17:12:11 -08:00
Ethan Furman
d986d1657e
bpo-41816: `StrEnum.__str__` is `str.__str__` (GH-22362)
...
use `str.__str__` for `StrEnum` so that `str(StrEnum.member)` is the same as directly accessing the string value of the `StrEnum` member
2020-09-22 13:00:07 -07:00
Ethan Furman
62e40d8450
Enum: add extended AutoNumber example (GH-22349)
2020-09-22 00:05:27 -07:00
Ethan Furman
0063ff4e58
bpo-41816: add `StrEnum` (GH-22337)
...
`StrEnum` ensures that its members were already strings, or intended to
be strings.
2020-09-21 17:23:13 -07:00
Ethan Furman
7219e27087
Enum: make `Flag` and `IntFlag` members iterable (GH-22221)
2020-09-16 13:01:00 -07:00
Ethan Furman
542e1df2b0
bpo-40721: add note about enum member name case (GH-22231)
...
* UPPER_CASE preferred as enum members are constants
2020-09-14 13:32:44 -07:00
Victor Stinner
d3ded08048
bpo-40204: Add :noindex: in the documentation (GH-21859)
...
Add :noindex: to duplicated documentation to fix "duplicate object
description" errors.
For example, fix this Sphinx 3 issue:
Doc/library/configparser.rst:1146: WARNING: duplicate object
description of configparser.ConfigParser.optionxform, other instance
in library/configparser, use :noindex: for one of them
2020-08-13 21:41:54 +02:00
E-Paine
1ee5dc1586
Remove trailing >>> in enum docs (GH-21358)
...
The >>> as the last line serve no purpose and are not colored correctly by Sphinx.
2020-07-09 12:18:34 -07:00
Ethan Onstott
d9a43e20fa
bpo-40025: Require _generate_next_value_ to be defined before members (GH-19098)
...
require `_generate_next_value_` to be defined before members
2020-04-28 10:20:55 -07:00
YoSTEALTH
24bcefcb74
bpo-39234: `enum.auto()` default initial value as 1 (GH-17878)
...
Updated as Eric mentioned "By default, the initial value starts at 1"
https://bugs.python.org/issue39234
Automerge-Triggered-By: @ericvsmith
2020-01-06 14:04:43 -08:00
YoSTEALTH
2e9012a3e1
bpo-39234: Doc: `enum.auto()` incrementation value not specified. (GH-17872)
...
* `enum.auto()` initial value is now specified as being `1`.
2020-01-06 11:53:36 -08:00
Antoine
d3c8d73514
Minor documentation fixes on library/enum (GH-15234)
...
* Minor documentation fixes on library/enum
2019-08-19 18:41:31 -07:00
thatneat
2f19e82fbe
bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ (GH-14545)
...
* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
2019-07-04 11:28:37 -07:00
nu_no
dfc8bb987d
Fix typo: class declaration (GH-11678)
2019-01-27 14:07:47 -08:00
Ethan Furman
5bdab641da
bpo-29577: Enum: mixin classes don't mix well with already mixed Enums (GH-9328)
...
* bpo-29577: allow multiple mixin classes
2018-09-21 19:03:09 -07:00
Ethan Furman
f52237400b
bpo-33437: add __new__ vs __init__ example (GH-9145)
...
Improve Enum docs.
https://bugs.python.org/issue33437
2018-09-12 10:00:30 -07:00
Rahul Jha
9430652535
bpo-33217: Raise TypeError for non-Enum lookups in Enums (GH-6651)
...
* bpo-33217: Raise TypeError for non-Enum lookups in Enums
2018-09-10 11:21:04 -07:00
Andrés Delfino
2d748389dc
Fix moduleauthor/sectionauthor directives in Enum (GH-8117)
2018-07-07 22:01:25 +03:00
INADA Naoki
e57f91a0f0
bpo-33866: enum: Stop using OrderedDict (GH-7698)
2018-06-19 01:14:26 +09:00
Ethan Furman
a4b1bb4801
bpo-31801: Enum: add _ignore_ as class option ( #5237 )
...
* 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_
2018-01-22 07:56:37 -08:00
Julian Kahnert
0f31c74fcf
Improve enum.Flag code example (GH-5167)
...
The code example that demonstrate how to use enum.Flag was missing
the import of enum.auto.
2018-01-12 19:35:57 -08:00
Kartik Anand
626584284e
correct documentation for enum.html ( #358 )
2017-02-28 21:07:18 +01:00
Berker Peksag
2a267a12ee
Issue #29129 : Fix typo in "Using auto" section
2017-01-02 05:51:04 +03:00
Ethan Furman
23bb6f48ea
close issue28172: Change all example enum member names to uppercase, per Guido; patch by Chris Angelico.
2016-11-21 09:22:05 -08:00
Ethan Furman
3515dcce80
issue23591: fix flag decomposition and repr
2016-09-18 13:15:41 -07:00
Ethan Furman
c16595e567
issue23591: add auto() for auto-generating Enum member values
2016-09-10 23:36:59 -07:00
Ethan Furman
54924df2b1
improve Enum docs
2016-09-07 23:40:31 -07:00
Ethan Furman
6a137e8d50
add recipes for pseudo-valueless enums
2016-09-07 08:17:15 -07:00
Ethan Furman
27682d2698
issue23591: more docs; slight change to repr
2016-09-04 11:39:01 -07:00
Ethan Furman
25d94bbf05
issue23591: bool(empty_flags) == False; more docs & tests
2016-09-02 16:32:32 -07:00
Ethan Furman
65a5a47d79
issue23591: add docs; code cleanup; more tests
2016-09-01 23:55:19 -07:00
Ethan Furman
e8e61277ff
issue26981: add _order_ compatibility shim to enum.Enum
2016-08-20 07:19:31 -07:00
Ethan Furman
332dbc7325
Issue26988: remove AutoEnum
2016-08-20 00:00:52 -07:00
Berker Peksag
43b586b951
Silence warnings from 'make suspicious' to make the docs buildbot happy
2016-08-06 13:37:22 +03:00
Ethan Furman
73fc586d9f
Add AutoEnum: automatically provides next value if missing. Issue 26988.
2016-08-05 16:03:16 -07:00
Martin Panter
2fec611a70
Issue #24314 : Merge doc links from 3.5
2016-06-18 08:20:22 +00:00
Martin Panter
bae5d81f5d
Issue #24314 : Fix doc links for general attributes like __name__, __dict__
2016-06-18 03:57:31 +00:00
Martin Panter
e514093a2f
Issue #27125 : Merge typo fixes from 3.5
2016-05-30 05:24:49 +00:00
Martin Panter
a90a4a9651
Issue #27125 : Remove duplicated words from documentation and comments
2016-05-30 04:04:50 +00:00
Martin Panter
bc1ee460dc
Issue #25179 : Documentation for formatted string literals aka f-strings
...
Some of the inspiration and wording is taken from the text of PEP 498 by Eric
V. Smith, and the existing str.format() documentation.
2016-02-13 00:41:37 +00:00
Martin Panter
46988d3659
Merge string formatting doc fixes from 3.5
2016-02-08 01:49:35 +00:00
Martin Panter
d5db14794b
Issue #25179 : Preparatory cleanup of existing docs on string formatting
...
* Various sections were pointing to the section on the string.Formatter
class, when the section on the common format string syntax is probably more
appropriate
* Fix references to various format() functions and methods
* Nested replacement fields may contain conversions and format specifiers,
and this is tested; see Issue #19729 for instance
2016-02-08 01:34:09 +00:00
Ethan Furman
2ae4ea54a2
use public 'value'
2016-01-16 12:39:53 -08:00
Ethan Furman
60255b67b9
revert change 87a9dff5106c: pure Enum members again evaluate to True;
...
update Finer Points section of docs to cover boolean evaluation;
add more tests for pure and mixed boolean evaluation
2016-01-15 15:01:33 -08:00
Ethan Furman
748dad5b6a
Close 25594: advise against accessing Enum members from other members
2015-11-20 13:12:26 -08:00
Ethan Furman
92e5d2f0eb
Close issue25594: advise against accessing Enum members from other members
2015-11-20 13:17:27 -08:00
Victor Stinner
91108f049f
Issue #25210 : Change error message of do_richcompare()
...
Don't add parenthesis to type names. Add also quotes around the type names.
Before:
TypeError: unorderable types: int() < NoneType()
After:
TypeError: '<' not supported between instances of 'int' and 'NoneType'
2015-10-14 18:25:31 +02:00
Martin Panter
84835ab1cb
Issue #25161 : Merge full stops from 3.4 into 3.5
2015-10-10 10:44:25 +00:00
Martin Panter
d21e0b52f1
Issue #25161 : Add full stops in documentation; patch by Takase Arihiro
2015-10-10 10:36:22 +00:00
Yury Selivanov
4dde587405
whatsnew/3.5: Sync whatsnew with versionadded/versionchanged doc tags
2015-09-11 00:48:21 -04:00
Ethan Furman
61f50bb488
Issue22997: minor doc update; thanks to Simoen Visser
2015-01-14 22:32:29 -08:00
Ethan Furman
8a12329281
Issue22997: minor doc update; thanks to Simoen Visser
2015-01-14 22:31:50 -08:00
Ethan Furman
8be6fac103
standardize Enum docs by referring to 'special methods' instead of __dunder__ methods
2014-11-01 07:40:22 -07:00
Georg Brandl
93a56cdc37
Doc: fix default role usage (except in unittest mock docs)
2014-10-30 22:25:41 +01:00
Berker Peksag
60efd79dc5
Issue #21706 : Add a versionchanged directive to the functional API docs.
2014-09-18 05:23:14 +03:00
Ethan Furman
d9925a18ec
Close issue21706: add 'start' parameter to functional API
2014-09-16 20:35:55 -07:00
Ethan Furman
f75805edb8
Issue21738: clarify usage of __new__ in Enum subclasses
2014-09-16 19:13:31 -07:00
Zachary Ware
dbd1c43e52
Fix spelling in enum docs.
...
"equivalant" was caught by Tobias Käs on docs@, "seperated" and "chartruese"
were discovered by a spell-checker.
2014-03-20 10:01:48 -05:00
Larry Hastings
3732ed2414
Merge in all documentation changes since branching 3.4.0rc1.
2014-03-15 21:13:56 -07:00
Ethan Furman
01cc2d5fb8
Issue20653: fix ReST for Enum
2014-03-03 15:02:04 -08:00
Ethan Furman
2da950460d
Close issue20653: improve functional API docs; minor code changes
2014-03-03 12:42:52 -08:00
Larry Hastings
ad88d7a26b
Python 3.4.0rc1 release: Updated pydoc topics, fixed suspicious markup errors.
2014-02-10 04:26:10 -08:00
Ethan Furman
ca1b794dac
Close issue20534: all pickle protocols now supported.
2014-02-08 11:36:27 -08:00
Ethan Furman
c72e638643
Close issue20412: Updated Enum docs to have referencable Enum and IntEnum classes
2014-02-06 08:13:14 -08:00
R David Murray
fd1ff1c888
Add versionadded to enum docs.
2013-12-20 14:20:49 -05:00
Serhiy Storchaka
98b28fddd8
Issue #18758 : Fixed and improved cross-references.
2013-10-13 23:12:09 +03:00
Ezio Melotti
17f1eddcfe
Add missing comma.
2013-10-05 04:26:06 +03:00
Ezio Melotti
93d7dda914
#19148 : fix markup errors and wording in enum docs. Patch by Esa Peuha.
2013-10-05 04:13:18 +03:00
Ethan Furman
9a1daf5765
Close #19011 : Add documentation on some of the non-standard Enum behavior.
...
Issues such as iterating and containment on Enum classes, why Enum member
instances do not show up on other Enum members, and how __new__ should
be used.
2013-09-27 22:58:06 -07:00
Ethan Furman
101e0746d3
Close #18989 : enum members will no longer overwrite other attributes, nor be overwritten by them.
2013-09-15 12:34:36 -07:00
Ethan Furman
455bfdea2f
Close #18980 : Enum doc fixes. Patch from Elazar Gershuni.
2013-09-08 23:48:34 -07:00
Ethan Furman
ed0bf8a729
Close #18908 : Keep Enum docs in their own section. Patch by Elazar Gershuni.
2013-09-06 19:53:30 -07:00
Ethan Furman
ec15a826ce
Close #18738 : Route __format__ calls to mixed-in type for mixed Enums (such as IntEnum).
2013-08-31 19:17:41 -07:00
Ethan Furman
9026262507
fixed examples to work with changed attribute names
2013-07-30 12:24:25 -07:00
Ethan Furman
f24bb35a69
closes issue18042 -- a `unique` decorator is added to enum.py
...
The docs also clarify the 'Interesting Example' duplicate-free enum is for
demonstration purposes.
2013-07-18 17:05:39 -07:00
Ethan Furman
e2563462fc
Added rationale for defaulting to 1 in the functional API.
2013-06-28 19:37:17 -07:00
Ethan Furman
3fe70b4acc
Added example to enum docs show access to name and value attributes of enum members.
2013-06-28 14:02:34 -07:00
Brett Cannon
15e489f7c5
Fix markup of the synopsis along with changing to state what is in the
...
module and not as a definition of what an enumeration is.
2013-06-14 21:59:16 -04:00
Ethan Furman
6b3d64ab5d
Closes issue 17947. Adds PEP-0435 (Adding an Enum type to the Python standard library).
...
Missing files added.
News entry added.
2013-06-14 16:55:46 -07:00