The signature for weakref.ReferenceType.__new__ seems to be saying the arguments can be named:
|
def __new__(cls, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ... |
If I try doing the following:
from weakref import ref
class Foo:
pass
def callback(_):
print("Deleted")
x = Foo()
y = ref(x, callback=callback)
pyright and mypy both seem happy with this, but in both Python 3.9 and 3.11 I get:
TypeError: ref() takes no keyword arguments
Should the parameters be renamed to __o and __callback to indicate they are positional-only?
The signature for
weakref.ReferenceType.__new__seems to be saying the arguments can be named:typeshed/stdlib/_weakref.pyi
Line 23 in 52cf716
If I try doing the following:
pyright and mypy both seem happy with this, but in both Python 3.9 and 3.11 I get:
Should the parameters be renamed to
__oand__callbackto indicate they are positional-only?