-
Notifications
You must be signed in to change notification settings - Fork 767
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
Incorrect type reported on hover with implicit optional parameter #2091
Comments
I agree this looks like a bug. I've created a corresponding issue in the pyright issue tracker. |
This will be fixed in the next release. |
This issue has been fixed in version 2021.12.0, which we've just released. You can find the changelog here: CHANGELOG.md |
I don't know whether I should open a new ticket or not but it seems like the See the below example: def hello_world(value: str = None):
print(value)
hello_world() The code also seems valid according to mypy: $ mypy type_test.py
Success: no issues found in 1 source file |
@hadim, this was an intentional change. About a year ago, PEP 484 was updated to recommend that type checkers do not use an implicit Optional by default. We decided to give users a bit of time before changing this default, but we did so recently. If you want the old (now deprecated) behavior, you can set If you are actively maintaining your code base, I'd encourage you to start moving away from implicit Optional. |
Thanks @erictraut. It makes sense and I'll switch my codebase to this practice from now on. |
Code:
If you put a
reveal_type(x)
in the middle, it showsstr | None
correctly.However, if you hover over
x
, you see juststr
.Seems at least confusing to me.
The text was updated successfully, but these errors were encountered: