Closed InSyncWithFoo closed 1 month ago
@InSyncWithFoo, as far as I can tell, Pylance doesn't have any support for deprecated overloads and PEP 702 explicitly chose to not add a way to deprecate parameters.
I'm not sure the added complexity of overloads here is worthwhile. What do you think about just removing the @deprecated
decorators?
Pylance doesn't have any support for deprecated overloads [...]
What do you mean? Deprecated overload usages are explicitly specified to be errors and Pyright is able to report them as such (playground):
@deprecated("Foobar")
@overload
def f(v: int, *, b: bool) -> None: ...
@overload
def f(v: int) -> None: ...
f(0, b = False) # error: The function "f" is deprecated
f(0) # fine
While it is true that there is no Deprecated[]
modifier, this limitation can be overcome by using @overload
s, and I don't see any reason not to do so.
Thanks. I'm not sure why I wasn't seeing this work before, but I see the diagnostic hint now.
The error text is a bit misleading since it starts off by saying that the function is deprecated, but as long as they keep reading through the descriptive text you added users should be ok.
Thanks for the contribution.
Instead, two
@deprecated
overloads were added with helpful messages to specify that onlysquared
is deprecated.Resolves #318.