-
Notifications
You must be signed in to change notification settings - Fork 27
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
Return type of CogniteResource.__new__ #1342
Comments
Hi @anrdnet! Our custom Any thoughts and proposals are very welcome 😄 |
It grew into a monstrosity, so I'm currently breaking it up into smaller PRs. Hopefully 1-2 weeks time 😄 |
@anrdnet Hey again! As of |
Pyright seems happy with the types now, thanks! |
Is your feature request related to a problem? Please describe.
The
CogniteResource
base class defineswhich is a bit odd since it's constructing an instance of
cls
, not necessarily aCogniteResource
directly.This ambiguity results in different behavior in different tools, which can be seen using the test program
In mypy there's special handling of
__new__
, so we get the expected resultbut pyright has a more literal interpretation
mypy also has a lot of open issues with handling different return types on
__new__
, and the behavior has changed several times recently. Relying on these workarounds seems fragile.Describe the solution you'd like
The signature used in the builtin type stubs for
object.__new__
beforetyping.Self
was introduced is akin toThis is supported by a developer of pyright.
Describe alternatives you've considered
pyright also has a workaround for
since this is often found in other code, but the generic approach seems better since it doesn't rely on workarounds in the different tools.
The text was updated successfully, but these errors were encountered: