-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add not_none #7
base: main
Are you sure you want to change the base?
Add not_none #7
Conversation
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
||
|
||
def test(x: Any, y: str | None, z: str) -> None: | ||
assert_type(not_none(x), Any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy fails on this one:
static_tests/test_not_none.py:10: error: Expression is of type <nothing>, not "Any" [assert-type]
Possibly fixable with overloads, let me try that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, now pyright fails with something worse:
/home/runner/work/useful_types/useful_types/static_tests/test_not_none.py:10:17 - error: "assert_type" mismatch: expected "Any" but received "Never" (reportGeneralTypeIssues)
I think I prefer the version without overloads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think might work with both if you reorder overloads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that way it doesn't narrow away the None at all, because None matches the first overload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use an if MYPY
trick to unblock this?
No description provided.