Skip to content

feat: Better typing (mypy) support for Unset (e.g., using if statements to check type) [#714, #752]. Thanks @taasan & @mcclurem! #752

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

Merged
merged 3 commits into from
Apr 30, 2023

Conversation

mcclurem
Copy link
Contributor

Mypy can't currently detect that an "Unset" is falsey. By changing the bool annotation in types.py, we can give it the help it needs

@dbanty
Copy link
Collaborator

dbanty commented Apr 24, 2023

Fixes #714, pretty sure it doesn't work in Python 3.7, though, so this will have to be after we drop support for it (which will be soon).

@mcclurem
Copy link
Contributor Author

Would ifdefing it with sys.version_info be considered acceptable to get it included sooner? Alternatively ifdefing an import of Literal from typing_extensions?

@dbanty
Copy link
Collaborator

dbanty commented Apr 25, 2023

3.7 is EoL in 2 months, so I'll probably just remove support in the next release

@dbanty dbanty changed the title help mypy figure out that 'Unset' is always falsey feat: Better typing (mypy) support for Unset (e.g., using if statements to check type) [#714, #752]. Thanks @taasan & @mcclurem! Apr 30, 2023
@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Merging #752 (5bfe3ec) into main (fdc5038) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #752   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         1971      1971           
=========================================
  Hits          1971      1971           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dbanty dbanty merged commit 5f2c702 into openapi-generators:main Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants