[issue46376] PyMapping_Check returns 1 for list

2022-01-25 Thread Ben Avrahami
Ben Avrahami added the comment: IMHO, I don't think any alternative to aviramha's solution addresses the issue, And I don't think the need is niche enough to be ignored. PyType_HasFeature excludes strings, bytes, and other esoteric types. PyMapping_Check includes mapping

[issue44695] asdict use deep copy to dataclass instances

2021-07-21 Thread Ben Avrahami
Change by Ben Avrahami : -- nosy: +avrahami.ben ___ Python tracker <https://bugs.python.org/issue44695> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36517] typing.NamedTuple does not support mixins

2021-02-09 Thread Ben Avrahami
Ben Avrahami added the comment: The patch PR blocks out a useful idiom: generic Nametuple >>> class LLNode(NamedTuple, Generic[T]): ... value :T ... next: Optional[LLNode[T]] I put forward that, at the least, NamedTuple should accept do-nothing bases like Generic. --

[issue42088] types.SimpleNamespace.__repr__ documentation inconsistency

2020-10-19 Thread Ben Avrahami
New submission from Ben Avrahami : According to the documentation for types.SimpleNamespace, `repr(SimpleNamespace())` should return `"SimpleNamespace()"`, but in actuality returns `"namespace()"`. This is because SimpleNamespace is an alias for the C implemented type

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-04 Thread Ben Avrahami
Ben Avrahami added the comment: > Adding a function to recalculate will require everyone to use it I'd argue that this is akin to `functools.update_wrapper`. It too is a function that must be called in virtually every function decorator (the only function decorators that don't

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-04 Thread Ben Avrahami
Ben Avrahami added the comment: Implementing this behavior automatically would be more complicated since you would also have to take subclasses into account. Current implementation enforces that the class is unused (as much as can be reasonably done) when its abstraction status is re

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-03 Thread Ben Avrahami
Ben Avrahami added the comment: > Maybe you misunderstand what I tried to say? Possibly, right now, total_ordering avoids overriding any method that is declared, either in the class or its superclasses (except for object), regardless of whether or not it is abstract. For it to be ABC-aw

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-03 Thread Ben Avrahami
Ben Avrahami added the comment: > I would prefer the isinstance(cls, ABCMeta) check to be inside that helper I had a little debate about this in my mind, I'll change it. > it's totally clear to me what @total_ordering should do -- it should define > __le__, __gt__ and

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-02 Thread Ben Avrahami
Ben Avrahami added the comment: This is a behavior that the PR changes. total_ordering should be able to override/implement abstract methods (in my opinion). If this ends up a strickling point then we can exclude total_ordering from this issue. Regardless, I think that this behavior is

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-02 Thread Ben Avrahami
Ben Avrahami added the comment: Good points all, that I will try to address one by one: Firstly, this function is by no means mandatory for "post-creation mixins". Such tools can still be used without calling it (and remain ABC unaware), with absolutely no change in functionali

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-01 Thread Ben Avrahami
Ben Avrahami added the comment: for the functionality to work, `total_ordering` needs to change to also override abstract methods. I believe this is an OK change since total_ordering implicitly dictates that the comparison methods are interchangable. Thus, implementing some comparison

[issue41905] add update_abstractmethods function to update an ABC's abstract methods

2020-10-01 Thread Ben Avrahami
New submission from Ben Avrahami : python-ideas discussion: https://mail.python.org/archives/list/python-id...@python.org/thread/6BNJ3YSEBPHEPGXSAZGBW3TJ64ZGZIHE/ In order to allow "decorator mixins" (most notably dataclass and total_ordering) to implement ABCs, new functionality is