Ethan Furman added the comment:
I'm not convinced this piece needs to be in the stdlib. Unlike other bits that
need extensive metaclass support this is trivial to add:
class DerivedEnumMeta(EnumMeta):
def __getitem__(cls, name):
try:
return cls._member_map_
Ethan Furman added the comment:
New changeset a4b1bb4801f7a941ff9e86b96da539be1c288833 by Ethan Furman in
branch 'master':
bpo-31801: Enum: add _ignore_ as class option (#5237)
https://github.com/python/cpython/commit/a4b1bb4801f7a941ff9e86b96da539
Ethan Furman added the comment:
New changeset 863b1e4d0e95036bca4e97c1b8b2ca72c19790fb by Ethan Furman
(mwidjaja) in branch 'master':
bpo-29237: Create enum for pstats sorting options (GH-5103)
https://github.com/python/cpython/commit/863b1e4d0e95036bca4e97c1b8b2ca
Change by Ethan Furman :
--
pull_requests: +5183
___
Python tracker
<https://bugs.python.org/issue29237>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
This functionality is now in the third-party aenum* library.
Are there any strong use-cases for this behavior such that it should be in the
stdlib?
* as of version 2.0.10, available on PyPI, and I am its author
--
nosy: +barry, eli.bendersky
Ethan Furman added the comment:
Thanks for catching that!
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Ethan Furman :
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
versions: +Python 3.7, Python 3.8
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
versions: +Python 3.8 -Python 3.6
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
Thanks for finding this!
However, TypeError, an exception, is not the correct type of answer -- the
correct type of answer for a yes/no question is either True or False.
So the code should be changed from returning NotImplemented to returning False
Ethan Furman added the comment:
issue33217 will not be "fixed" with a TypeError, but incorrect Falses are also
bad.
Rather than add __contains__ to IntFlag (and every other Flag mixin), I think
the best answer is to adjust Flag.__contains__ a little bit more to check if
`other`
Ethan Furman added the comment:
Strings are actually the odd-man out -- dicts, sets, lists, tuples, etc., all
return False instead of raising TypeError.
The reason str raises an error is because `in`, for str, is a substring check,
not a membership check
Ethan Furman added the comment:
Stepping back slightly, it is more general to say that str, and in certain
other cases dict and set (and possibly others) will raise instead of return
False when it is impossible for the target type to ever hold the checked-for
type. A couple examples of what
Ethan Furman added the comment:
Nitish, Flag can check if the current Flag class has a mixin, and if so if the
object being checked for is of that same type.
Dutcho, my apologies. Looks like I did not fully understand how __contains__
is supposed to work and a TypeError is completely
Ethan Furman added the comment:
issue33217 is tracking member-containment checks; modifying this one to track
class-containment checks.
Given
class Color(Enum):
RED = 1
class Fruit(Enum):
APPLE = 1
then
--> Fruit.APPLE in Color
False
--> Fruit.APPLE in Fruit
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +6100
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue33217>
___
___
Py
Change by Ethan Furman :
--
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue33233>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
New changeset 3715176557cf87925c8f89b98939c7daf9bf48e2 by Ethan Furman in
branch '3.7':
[3.7] bpo-33217: deprecate non-Enum lookups in Enums (GH-6392)
https://github.com/python/cpython/commit/3715176557cf87925c8f89b98939c7
Ethan Furman added the comment:
This and issue33217 are similar enough I'm going to track it in issue33217.
--
resolution: -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder: -> x in enum.Flag member is True whe
Ethan Furman added the comment:
DeprecationWarning is in 3.7, now need to raise TypeError in 3.8.
--
stage: patch review -> needs patch
versions: -Python 3.6
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset b8e21f12891382bc0aac5ccd13dcb4a990d65e0a by Ethan Furman
(anentropic) in branch 'master':
bpo-31947: remove None default for names param in Enum._create_ (GH-4288)
https://github.com/python/cpython/commit/b8e21f12891382bc0aac5ccd13dcb4
Ethan Furman added the comment:
Rahul Jha, sure, go ahead!
--
___
Python tracker
<https://bugs.python.org/issue33217>
___
___
Python-bugs-list mailing list
Unsub
Ethan Furman added the comment:
Setting _value_ needs to happen in __new__ for those cases where another data
type, such as str or int, is mixed in.
I'll look at adding an example to the docs.
Thanks for the report!
--
assignee: -> ethan.furman
components: +Documentat
Ethan Furman added the comment:
That new example looks great! Note that you don't need the parenthesis, though.
FYI: The same thing using the aenum library* would look like:
from aenum import Enum
class Coord(bytes, Enum):
_init_ = 'value label unit'
PX =
Ethan Furman added the comment:
New changeset c50e5b1f1f2501f697aa52d9c9a440bdeced7006 by Ethan Furman (Miss
Islington (bot)) in branch '3.6':
bpo-31947: remove None default for names param in Enum._create_ GH-4288
(GH-6485)
https://github.com/python/cpyt
Ethan Furman added the comment:
Thank you, Anentropic!
--
assignee: -> ethan.furman
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python
Ethan Furman added the comment:
IntFlag.__and__ does not create a new instance every time -- all new instances
are cached in the IntFlag machinery (so RegexFlag(7) is only created once).
If all the RegexFlag combinations are created before the regex compile
benchmark do we still see a speed
Ethan Furman added the comment:
INADA Naoki said:
> But while new instance is not created each time, 4 Python method
> calls (e,g. IntFlag.__and__() -> IntFlag.__new__()
> -> IntFlag._missing_() -> IntFlag._create_pseudo_member_())
> are much slower than int & int.
New submission from Ethan Furman :
The following code should work (from
https://stackoverflow.com/a/46780742/208880):
class BaudRate(Enum):
cls = vars()
regexp = r"(?:^|,)B(?P\d+)"
rates = sorted(map(int, re.findall(regexp, ",".join(dir(term
Ethan Furman added the comment:
I agree with MAL; removing functions just makes multi-version code more
painful. At least have the DeprecationWarning active for two releases before
removing it.
--
nosy: +ethan.furman
___
Python tracker
<ht
Change by Ethan Furman :
--
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue31742>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
We definitely need time with either DeprecationWarning or FutureWarning before
removing/substituting a function.
--
___
Python tracker
<https://bugs.python.org/issue31
Ethan Furman added the comment:
I make sure to use %r in error-reporting and debugging messages precisely
because it's output is (usually) valid python. If I see a 1 without quotes I
know it's a number, and with quotes I know it's a string.
-1
--
nosy
Ethan Furman added the comment:
Yup, I sure did. :/
Looks like a good change to me. Are these the only instances of quotes used
with %r?
--
___
Python tracker
<https://bugs.python.org/issue32
Change by Ethan Furman :
--
Removed message: https://bugs.python.org/msg307149
___
Python tracker
<https://bugs.python.org/issue32157>
___
___
Python-bugs-list m
Ethan Furman added the comment:
Serhiy is correct. The exact return type only needs to be ordered, and have
appropriate dictionary methods such as `keys()`, `values()`, and `items()`.
The reason a mappingproxy was chosen is exactly because what you just tried is
illegal and/or confusing
New submission from Ethan Furman :
Checking the docs for Enum I see that section 8.13.15.3.1 says:
`__members__` is an `OrderedDict`
which is incorrect. It should say "an ordered dictionary".
--
messages: 319543
nosy: adelfino, barry, eli.bendersky, ethan.furman
priori
Ethan Furman added the comment:
I am open to suggestions, but I will say that there are other types of ordered
dictionaries besides OrderedDict. Also, if you have some generic dictionary
that happens to be ordered but is not an OrderedDict, how would you describe it
Ethan Furman added the comment:
An ordered mapping sounds good to me. Let's let this sit for a couple days in
case anyone else wants to chime in. If there are no other ideas or objections
then we can make the change mid-next week.
--
___
P
Change by Ethan Furman :
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
___
Python tracker
<https://bugs.python.org/issue33866>
___
_
Ethan Furman added the comment:
As I said on the PR:
This feels like an unnecessary change. The phrase "ordered dictionary" does not
always refer to an 'OrderedDict`, and there is more than one way to order a
dictionary besides insertion order.
As a side note: it's gene
Ethan Furman added the comment:
Closing as a duplicate of #33866. My apologies for the fractured discussion.
At this point I'm going to leave/update the documentation using "an ordered
dictionary". See #33866 for further discussion.
--
assignee: -> ethan
Ethan Furman added the comment:
Edward, thank you for taking the time to submit a patch, complete with tests!
Do you have a real-world example of why Enum should work this way?
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.fur
Change by Ethan Furman :
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
___
Python tracker
<https://bugs.python.org/issue34082>
___
_
Ethan Furman added the comment:
Markus Wegmann said:
> In the appendix, you find a toy project with similar structure, which > in
> contrast to `flora_tools` works flawlessly.
I appreciate your attempt to reproduce the problem, but since you weren't able
Ethan Furman added the comment:
What you have discovered is not Enum specific, but in fact can happen with any
module (as stated in my first comment in this bug report).
Maybe these SO question will help:
https://stackoverflow.com/q/2489601/208880
https://stackoverflow.com/a/4798648/208880
Change by Ethan Furman :
--
assignee: -> ethan.furman
___
Python tracker
<https://bugs.python.org/issue34443>
___
___
Python-bugs-list mailing list
Unsubscrib
Ethan Furman added the comment:
All those attributes live in the Enum class. If you use a non-existent
attribute, such as _name, then the metaclass will be called to check if that
name is actually an Enum member.
--
assignee: docs@python -> ethan.furman
nosy: +ethan.fur
Change by Ethan Furman :
--
assignee: -> ethan.furman
___
Python tracker
<https://bugs.python.org/issue27923>
___
___
Python-bugs-list mailing list
Unsubscrib
Ethan Furman added the comment:
For versions 3.6 and 3.7 the solution is to modify the shadow check at line 236
so only DynamicClassAttributes are /not/ shadowed (meaning the _convert method
would be shadowed by an _convert member).
For 3.8 we can move _convert to the metaclass: I wasn
Change by Ethan Furman :
--
Removed message: https://bugs.python.org/msg324414
___
Python tracker
<https://bugs.python.org/issue34282>
___
___
Python-bugs-list m
Ethan Furman added the comment:
For versions 3.6 and 3.7 the solution is to modify the shadow check at line 236
so only DynamicClassAttributes are /not/ shadowed (meaning the _convert method
would be shadowed by an _convert member).
For 3.8 we can move _convert to the metaclass: I wasn
Change by Ethan Furman :
--
assignee: -> ethan.furman
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue34536>
___
___
Python-bugs-list mai
Ethan Furman added the comment:
On 09/01/2018 01:21 AM, orlnub123 wrote:
> On 08/31/2018 03:01 ethan.furman wrote:
>> For versions 3.6 and 3.7 the solution is to modify the shadow check at
>> line 236 so only DynamicClassAttributes are /not/ shadowed (meaning
>> the _co
Ethan Furman added the comment:
orlnub123 wrote:
---
> In my testings _convert has always been available to them as they all
> subclass Enum where it's defined.
Wow, I really shouldn't check for things in the middle of the night. On the
bright side, no further ch
Ethan Furman added the comment:
New changeset c0d63bf73b35df374e6e66c08b0e297fb828d744 by Ethan Furman
(orlnub123) in branch '3.7':
[3.7] bpo-34282: Fix Enum._convert method shadowing members named _convert
(GH-9034)
https://github.com/python/cpyt
Change by Ethan Furman :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue34487>
___
___
Ethan Furman added the comment:
New changeset 9430652535f88125d8003f342a8884d34885d876 by Ethan Furman (Rahul
Jha) in branch 'master':
bpo-33217: Raise TypeError for non-Enum lookups in Enums (GH-6651)
https://github.com/python/cpython/commit/9430652535f88125d8003f342a8884
Ethan Furman added the comment:
Thank you, Rahul!
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Ethan Furman :
--
pull_requests: +8593
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue33437>
___
___
Python-bugs-list mai
Ethan Furman added the comment:
The solution to 29577 will also fix this.
--
resolution: -> duplicate
stage: -> resolved
status: open -> closed
superseder: -> Enum: mixin classes don't mix well with already mixed Enums
___
Pytho
Ethan Furman added the comment:
Serhiy said:
---
> I think using more longer name in repr and/or str for *instances* of
> enum classes is not good idea. They are already verbose, and this
> will make them more verbose.
I'm okay with verbose reprs, as debugging is the p
Ethan Furman added the comment:
Okay, I might be changing my mind. In most cases I suspect the difference
would be minimal, but when it isn't, it really isn't. Take this example from a
pydoc test:
class Color(enum.Enum)
| Color(value, names=None, *, module=None, qualname=
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +8636
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue34536>
___
___
Py
Change by Ethan Furman :
--
keywords: +patch, patch, patch
pull_requests: +8636, 8637, 8638
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
keywords: +patch, patch
pull_requests: +8636, 8637
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset 0fb9fadd3b3e9e3698647e0b92d49b0b7aacd979 by Ethan Furman
(orlnub123) in branch 'master':
bpo-34282: Fix Enum._convert shadowing members named _convert (GH-8568)
https://github.com/python/cpython/commit/0fb9fadd3b3e9e3698647e0b92d49b
Change by Ethan Furman :
--
versions: +Python 3.8 -Python 3.6, Python 3.7
___
Python tracker
<https://bugs.python.org/issue29577>
___
___
Python-bugs-list mailin
Ethan Furman added the comment:
New changeset 019f0a0cb85ebc234356415f3638b9bd77528e55 by Ethan Furman in
branch 'master':
bpo-34536: raise error for invalid _missing_ results (GH-9147)
https://github.com/python/cpython/commit/019f0a0cb85ebc234356415f3638b9
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +8751
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue29577>
___
___
Py
Ethan Furman added the comment:
`locals()` returns the dictionary being used (an _EnumDict) and direct
assignment uses the `__setitem__` method, which has been overridden -- and it
is the only one; so `update()`, etc., still have normal dict meanings and not
Enum ones.
Next step: compile
Ethan Furman added the comment:
New changeset 5bdab641da0afd8aa581dfbde4f82d88d337c4b5 by Ethan Furman in
branch 'master':
bpo-29577: Enum: mixin classes don't mix well with already mixed Enums (GH-9328)
https://github.com/python/cpython/commit/5bdab641da0afd8aa581dfbde
Change by Ethan Furman :
--
pull_requests: +8896
___
Python tracker
<https://bugs.python.org/issue29577>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
New changeset 0c076caaa82a9c6596e1fe1dbe6384d53f30a1a3 by Ethan Furman in
branch '3.7':
[3.7] bpo-29577: Enum: mixin classes don't mix well with already mixed Enums
(GH-9328) (GH-9486)
https://github.com/python
New submission from Ethan Furman :
from enum import Enum, unique
class StrEnum(str, Enum):
def __new__(cls, *args, **kwargs):
for a in args:
if not isinstance(a, str):
raise TypeError("Enumeration '%s' (%s) is not"
Ethan Furman added the comment:
It really is. I got a message from Michal Arbet from OpenStack about it.
I just finished the fix and am currently running the tests locally. Is it okay
to have the PR directly against 3.7 instead of doing 3.8 first and backporting?
--
stage: test
Ethan Furman added the comment:
New changeset 22e86fbbca04d251233fc07515885d2b67945094 by Ethan Furman (Miss
Islington (bot)) in branch '3.6':
[3.7] bpo-34282: Fix Enum._convert method shadowing members named _convert
(GH-9034) (GH-9229)
https://github.com/python/cpyt
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +9124
stage: needs patch -> patch review
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset cd45385ffad8910293e5659cfe7ab036e70613b7 by Ethan Furman in
branch 'master':
bpo-34909: keep searching mixins until base class is found (GH-9737)
https://github.com/python/cpython/commit/cd45385ffad8910293e5659cfe7ab0
Ethan Furman added the comment:
New changeset 453b3b0e87cb16345c276b9064a4480ce3794a74 by Ethan Furman (Miss
Islington (bot)) in branch '3.7':
bpo-34909: keep searching mixins until base class is found (GH-9737) (GH-9738)
https://github.com/python/cpyt
Ethan Furman added the comment:
Stéphane, thanks for the tip about bisect!
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
On 10/12/2018 09:52 PM, Ned Deily wrote:
> Can you please merge a NEWS item for this issue using blurb since it
> is a user-visible problem? I'll cherry-pick it into the 3.7.1 final.
I don't believe the problem exists in 3.7.0 -- but I als
Ethan Furman added the comment:
Working on getting that news entry.
--
___
Python tracker
<https://bugs.python.org/issue34909>
___
___
Python-bugs-list mailin
Ethan Furman added the comment:
Okay, the patch is here:
https://github.com/ethanfurman/cpython/tree/enum_news_entry
But I managed to screw something up, and my wife just got hit by a car so this
is now a really low priority.
Ned, if you could grab the relevant pieces from the wreck that
Ethan Furman added the comment:
Change by STINNER Victor:
> pull_requests: +9319
Why does the above say 9319 when the PR is 9978?
--
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset 0f2fc8bee0b435ee2934751264196db30d16ed8a by Ethan Furman (Victor
Stinner) in branch '3.7':
bpo-34536: raise error for invalid _missing_ results (GH-9147) (GH-9978)
https://github.com/python/cpython/commit/0f2fc8bee0b435ee2934751264196d
Ethan Furman added the comment:
New changeset 4acf6c9d4be77b968fa498569d7a1545e5e77344 by Ethan Furman (Victor
Stinner) in branch 'master':
bpo-34536: Cleanup test_enum imports (GH-9979)
https://github.com/python/cpython/commit/4acf6c9d4be77b968fa498569d7a15
Ethan Furman added the comment:
Thank you both.
--
___
Python tracker
<https://bugs.python.org/issue34909>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
Wow. I definitely felt like an apprentice after reading the changes. Thanks,
Eli, that looks worlds better!
--
___
Python tracker
<http://bugs.python.org/issue17
Ethan Furman added the comment:
Working on documentation...
--
___
Python tracker
<http://bugs.python.org/issue17947>
___
___
Python-bugs-list mailing list
Unsub
Ethan Furman added the comment:
Hopefully the final bit of code, plus docs.
Code changes:
_names_ are reserved
Doc changes (different from the PEP):
examples of AutoEnum, UniqueEnum, and OrderedEnum
--
Added file: http://bugs.python.org/file30504/pep-0435.08.stoneleaf.patch
Changes by Ethan Furman :
Removed file: http://bugs.python.org/file30504/pep-0435.08.stoneleaf.patch
___
Python tracker
<http://bugs.python.org/issue17947>
___
___
Pytho
Changes by Ethan Furman :
Added file: http://bugs.python.org/file30505/pep-0435.08.stoneleaf.patch
___
Python tracker
<http://bugs.python.org/issue17947>
___
___
Pytho
Changes by Ethan Furman :
Removed file: http://bugs.python.org/file30505/pep-0435.08.stoneleaf.patch
___
Python tracker
<http://bugs.python.org/issue17947>
___
___
Pytho
Ethan Furman added the comment:
Apologies for the noise -- was having trouble getting the correct patch
attached. :/
--
Added file: http://bugs.python.org/file30506/pep-0435.09.stoneleaf.patch
___
Python tracker
<http://bugs.python.org/issue17
Ethan Furman added the comment:
So, which is better?
To have a @unique class decorator as part of the module, or to have a
UniqueEnum recipe in the docs?
A decorator is immediately usable, but requires remembering an extra line of
code.
An example requires being put into a local utility
Ethan Furman added the comment:
Good idea, thanks.
--
___
Python tracker
<http://bugs.python.org/issue17947>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
Doc updates are in.
I removed the 'unique, constant' from the first line of the intro, as neither
of those things are necessarily true.
--
Added file: http://bugs.python.org/file30511/pep-0435.10.stone
Ethan Furman added the comment:
Hmm -- I was confusing member names with member values; I'll put 'unique' back
in.
--
___
Python tracker
<http://bugs.pyt
Ethan Furman added the comment:
Hopefully the last update. :)
--
Added file: http://bugs.python.org/file30512/pep-0435.11.stoneleaf.patch
___
Python tracker
<http://bugs.python.org/issue17
601 - 700 of 1868 matches
Mail list logo