Replies: 1 comment
-
Yes, you'll need to explicitly annotate And yes, I agree that it seems somewhat inconsistent. That was my hesitation in making this change. But it's a huge performance win, so I think it's the right tradeoff. Other type checkers like mypy and pyre don't perform return type inference in any manner, so pyright is already going well beyond what they do. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I was about to open a bug for a
NoReturn
type narrowing regression in 1.1.300 but then noticed:Indeed I just got hit by that inconsistent type evaluation. All my return types are implicit return types (when not writing a library with a contractual API) so I can fully leverage type inference and not have to constantly tweak return type annotations.
I have
exit_program
method that cleans everything up before callingsys.exit()
. It looks something like this (shortened version, just for context):Easy fix, just add
-> NoReturn
. But it does raise the concern that it looks like a bug and seems inconsistent when I see:and
I understand that
, just voicing concern over a very confusing and inconsistent type reporting. Maybe having
Unknown
instead ofNoReturn
as the revealed type for implicitNoReturn
would be fine? That's how it acts anyway. And/or a more visible way for the user to know infered return type doesn't work forNoReturn
Beta Was this translation helpful? Give feedback.
All reactions