-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
stdlib.weakref:finalize
todo clarification
#8437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note, the use of _P.args in the tuple I believe is not allowed, though it's how as a user I had originally understood and expected ParamSpec to work. Similar to how I expected it to be able to be bound to a function so that you could re-use a parameter specification of an existing function in other functions, essentially always keeping them up to date. |
Cc @sobolevn as author of that comment. |
Yes, I was thinking about typing methods like def detach(self):
"""If alive then mark as dead and return (obj, func, args, kwargs);
otherwise return None"""
info = self._registry.get(self)
obj = info and info.weakref()
if obj is not None and self._registry.pop(self, None):
return (obj, info.func, info.args, info.kwargs or {}) |
Closing as I fundamentally disagree with the suggested fix of simply removing the todo. |
In weakref.pyi, there is the following todo:
https://github.com/python/typeshed/blob/master/stdlib/weakref.pyi#L127
Looking at the documentation for
finalize
, seen here I can see that:And is constructed with the object, callable, etc. The implementation is seen here:
https://github.com/python/cpython/blob/main/Lib/weakref.py#L540
I was wondering if this could be clarified to help me understand what the correct way to implement that was.
As I understand the docs of finalize though, I think this would be:
Any tips would be appreciated
The text was updated successfully, but these errors were encountered: