-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
stdlib: use bool
for annotations where the default is False
#9672
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
Conversation
bool
for annotations where the default is False
bool
for annotations where the default is False
Diff from mypy_primer, showing the effect of this PR on open source code: isort (https://github.com/pycqa/isort)
+ isort/api.py:196: error: No overload variant of "compile" matches argument types "str", "str", "str", "int", "int" [call-overload]
+ isort/api.py:196: note: Possible overload variants:
+ isort/api.py:196: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[0], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> CodeType
+ isort/api.py:196: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, *, dont_inherit: bool = ..., optimize: int = ..., _feature_version: int = ...) -> CodeType
+ isort/api.py:196: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[1024], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> AST
+ isort/api.py:196: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: int, dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> Any
+ isort/api.py:223: error: No overload variant of "compile" matches argument types "str", "str", "str", "int", "int" [call-overload]
+ isort/api.py:223: note: Possible overload variants:
+ isort/api.py:223: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[0], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> CodeType
+ isort/api.py:223: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, *, dont_inherit: bool = ..., optimize: int = ..., _feature_version: int = ...) -> CodeType
+ isort/api.py:223: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[1024], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> AST
+ isort/api.py:223: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: int, dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> Any
streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/runtime/scriptrunner/script_runner.py: note: In member "_run_script" of class "ScriptRunner":
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: error: No overload variant of "compile" matches argument types "Any", "str", "str", "int", "int", "int" [call-overload]
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note: Possible overload variants:
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[0], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> CodeType
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, *, dont_inherit: bool = ..., optimize: int = ..., _feature_version: int = ...) -> CodeType
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: Literal[1024], dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> AST
+ lib/streamlit/runtime/scriptrunner/script_runner.py:495:20: note: def compile(source: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], Module, Expression, Interactive], filename: Union[str, Union[bytes, Union[bytearray, memoryview, array[Any], mmap, _CData, PickleBuffer]], _PathLike[Any]], mode: str, flags: int, dont_inherit: bool = ..., optimize: int = ..., *, _feature_version: int = ...) -> Any
|
It looks like a big fallout because of the verbose error messages, but in actual fact that's only 3 new hits being reported in user code. I could also just revert the changes to |
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 like the simple defaults in stubs :)
I think it's fine to get a new mypy error for using an integer as the |
Then let's do it. |
Found by grepping for
: int = False
(I also grepped for
: int = True
, but there weren't any hits.)