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
Change by Ben Avrahami :
--
nosy: +avrahami.ben
___
Python tracker
<https://bugs.python.org/issue44695>
___
___
Python-bugs-list mailing list
Unsubscribe:
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.
--
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
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
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
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
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
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
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
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
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
12 matches
Mail list logo