| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Python 3 allows calling NoneType() and type(None)():
>>> NoneType()
None
>>> type(None)()
None
But mypy raised an "unsupported_type_type" error in analyze_type_type_callee
when encountering a Type[None] callee. Fixed by adding isinstance(item, NoneType)
branch that returns a zero-argument CallableType returning NoneType.
Fixes python#19660.
for more information, see https://pre-commit.ci
`output` in Options defaults to None (meaning unset). The config parser skips options when getattr(template, key, None) returns None, so `output = json` in mypy.ini was silently ignored. Fixed by adding `"output": str` to both ini_config_types and toml_config_types, so the option is recognized and properly set. Fixes python#21376.
There was a problem hiding this comment.
This PR fixes issue #21376, adding to the config types list allowing it to be set in mypy.ini / mypy.toml. The change is minimal and follows the existing pattern. Could I get a review?
Sorry, something went wrong.
|
Hi maintainers! This PR allows instantiating type[None] and type(None), which were previously rejected by mypy. Happy to make any adjustments if you have feedback. |
Sorry, something went wrong.
|
Oh sorry, I didn't notice the output config option was in this PR too.. hmm. If it works, please submit a new PR. It's a different approach than #21416 so presumably one of the approaches is worse :-) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Python 3 allows calling NoneType() and type(None)():
But mypy raised an Unsupported type type "NoneType" error when analyzing these callees.
Fix
In analyze_type_type_callee() (mypy/checkexpr.py), added an isinstance(item, NoneType) branch that returns a zero-argument CallableType returning NoneType. This allows both NoneType() and type(None)() to type-check correctly.
Fixes #19660.