mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Resolve EncodingWarnings

Open dmtucker opened this issue 2 years ago • 4 comments

Resolve #14603

encoding should be explicit, even when opting for the default behavior ("locale") https://peps.python.org/pep-0597/

This is motivated by eliminating EncodingWarnings in pytest-mypy.

dmtucker avatar Feb 11 '23 03:02 dmtucker

Would it be appropriate to use "utf-8" instead of "locale" (which isn't added until 3.10)?

dmtucker avatar Feb 11 '23 03:02 dmtucker

Diff from mypy_primer, showing the effect of this PR on open source code:

downforeveryone (https://github.com/rpdelaney/downforeveryone)
- Warning: unused section(s) in pyproject.toml: module = ['.venv.*']
+ Traceback (most recent call last):
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
+     sys.exit(console_entry())
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
+     main()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 95, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 174, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 194, in build
+     result = _build(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 277, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2870, in dispatch
+     graph = load_graph(sources, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 3055, in load_graph
+     st = State(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2007, in __init__
+     self.compute_dependencies()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2296, in compute_dependencies
+     dep_entries = manager.all_imported_modules_in_file(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 811, in all_imported_modules_in_file
+     if self.is_module(sub_id):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 838, in is_module
+     return find_module_simple(id, self) is not None
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2719, in find_module_simple
+     x = find_module_with_reason(id, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2728, in find_module_with_reason
+     x = manager.find_module_cache.find_module(id)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 308, in find_module
+     self.results[id] = self._find_module(id, use_typeshed)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 434, in _find_module
+     if fscache.isdir(stub_dir) and self._is_compatible_stub_package(stub_dir):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 579, in _is_compatible_stub_package
+     with open(metadata_fnam, "rb", encoding="locale") as f:
+ ValueError: binary mode doesn't take an encoding argument

xarray (https://github.com/pydata/xarray)
- conftest.py: error: Duplicate module named "conftest" (also at "./properties/conftest.py")
- conftest.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
- conftest.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
+ Traceback (most recent call last):
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
+     sys.exit(console_entry())
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
+     main()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 95, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 174, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 194, in build
+     result = _build(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 277, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2870, in dispatch
+     graph = load_graph(sources, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 3055, in load_graph
+     st = State(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2007, in __init__
+     self.compute_dependencies()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2296, in compute_dependencies
+     dep_entries = manager.all_imported_modules_in_file(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 811, in all_imported_modules_in_file
+     if self.is_module(sub_id):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 838, in is_module
+     return find_module_simple(id, self) is not None
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2719, in find_module_simple
+     x = find_module_with_reason(id, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2728, in find_module_with_reason
+     x = manager.find_module_cache.find_module(id)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 308, in find_module
+     self.results[id] = self._find_module(id, use_typeshed)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 434, in _find_module
+     if fscache.isdir(stub_dir) and self._is_compatible_stub_package(stub_dir):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 579, in _is_compatible_stub_package
+     with open(metadata_fnam, "rb", encoding="locale") as f:
+ ValueError: binary mode doesn't take an encoding argument

apprise (https://github.com/caronc/apprise)
+ Traceback (most recent call last):
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
+     sys.exit(console_entry())
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
+     main()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 95, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 174, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 194, in build
+     result = _build(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 277, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2870, in dispatch
+     graph = load_graph(sources, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 3055, in load_graph
+     st = State(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2007, in __init__
+     self.compute_dependencies()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2296, in compute_dependencies
+     dep_entries = manager.all_imported_modules_in_file(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 811, in all_imported_modules_in_file
+     if self.is_module(sub_id):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 838, in is_module
+     return find_module_simple(id, self) is not None
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2719, in find_module_simple
+     x = find_module_with_reason(id, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2728, in find_module_with_reason
+     x = manager.find_module_cache.find_module(id)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 308, in find_module
+     self.results[id] = self._find_module(id, use_typeshed)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 434, in _find_module
+     if fscache.isdir(stub_dir) and self._is_compatible_stub_package(stub_dir):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 579, in _is_compatible_stub_package
+     with open(metadata_fnam, "rb", encoding="locale") as f:
+ ValueError: binary mode doesn't take an encoding argument
- apprise/common.pyi:22: error: Name "NotifyBase" is not defined  [name-defined]
- setup.py:38: error: Skipping analyzing "setuptools": module is installed, but missing library stubs or py.typed marker  [import]
- setup.py:42: error: Library stubs not installed for "babel.messages"  [import]
- setup.py:42: note: Hint: "python3 -m pip install types-babel"
- apprise/attachment/__init__.py:37: error: Module "apprise.common" has no attribute "ATTACHMENT_SCHEMA_MAP"  [attr-defined]
- apprise/logger.py:41: error: Module has no attribute "TRACE"  [attr-defined]
- apprise/logger.py:45: error: Module has no attribute "DEPRECATE"  [attr-defined]
- apprise/logger.py:48: error: Module has no attribute "DEPRECATE"  [attr-defined]
- apprise/logger.py:49: error: Module has no attribute "TRACE"  [attr-defined]
- apprise/logger.py:69: error: "Type[Logger]" has no attribute "trace"  [attr-defined]
- apprise/logger.py:70: error: "Type[Logger]" has no attribute "deprecate"  [attr-defined]
- apprise/URLBase.pyi:1: error: Module "logging" has no attribute "logger"; maybe "Logger"?  [attr-defined]
- apprise/conversion.py:106: error: Need type annotation for "BLOCK_END" (hint: "BLOCK_END: Dict[<type>, <type>] = ...")  [var-annotated]
- apprise/config/__init__.py:38: error: Module "apprise.common" has no attribute "CONFIG_SCHEMA_MAP"  [attr-defined]
- apprise/config/ConfigBase.pyi:3: error: Module "apprise.URLBase" is not valid as a type  [valid-type]
- apprise/config/ConfigBase.pyi:3: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/config/ConfigBase.pyi:3: error: Invalid base class "URLBase"  [misc]
- apprise/AppriseConfig.pyi:3: error: Name "AppriseAsset" already defined (by an import)  [no-redef]
- apprise/AppriseConfig.pyi:6: error: Module "apprise.config.ConfigBase" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:6: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:12: error: Module "apprise.AppriseAsset" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:12: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:21: error: Module "apprise.AppriseAsset" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:21: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:29: error: Module "apprise.AppriseAsset" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:29: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:35: error: Module "apprise.config.ConfigBase" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:35: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:36: error: Self argument missing for a non-static method (or an invalid type for self)  [misc]
- apprise/AppriseConfig.pyi:38: error: Module "apprise.AppriseAsset" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:38: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:43: error: Module "apprise.config.ConfigBase" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:43: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:44: error: Module "apprise.config.ConfigBase" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:44: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:45: error: Module "apprise.config.ConfigBase" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:45: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseConfig.pyi:47: error: Module "apprise.config.ConfigBase" is not valid as a type  [valid-type]
- apprise/AppriseConfig.pyi:47: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseAttachment.pyi:3: error: Name "AppriseAsset" already defined (by an import)  [no-redef]
- apprise/AppriseAttachment.pyi:6: error: Module "apprise.attachment.AttachBase" is not valid as a type  [valid-type]
- apprise/AppriseAttachment.pyi:6: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseAttachment.pyi:27: error: Module "apprise.AppriseAsset" is not valid as a type  [valid-type]
- apprise/AppriseAttachment.pyi:27: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseAttachment.pyi:30: error: Name "NotifyBase" is not defined  [name-defined]
- apprise/AppriseAttachment.pyi:33: error: Module "apprise.attachment.AttachBase" is not valid as a type  [valid-type]
- apprise/AppriseAttachment.pyi:33: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseAttachment.pyi:34: error: Module "apprise.attachment.AttachBase" is not valid as a type  [valid-type]
- apprise/AppriseAttachment.pyi:34: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/AppriseAttachment.pyi:36: error: Name "Iterator" is not defined  [name-defined]
- apprise/AppriseAttachment.pyi:36: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Iterator")
- apprise/Apprise.pyi:3: error: Name "AppriseAsset" already defined (by an import)  [no-redef]
- apprise/Apprise.pyi:3: error: Name "AppriseAttachment" already defined (by an import)  [no-redef]
- apprise/Apprise.pyi:3: error: Name "AppriseConfig" already defined (by an import)  [no-redef]
- apprise/Apprise.pyi:7: error: Name "Union" is not defined  [name-defined]
- apprise/Apprise.pyi:7: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Union")
- apprise/Apprise.pyi:8: error: Name "Union" is not defined  [name-defined]
- apprise/Apprise.pyi:8: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Union")
- apprise/Apprise.pyi:8: error: Variable "apprise.Apprise._Server" is not valid as a type  [valid-type]
- apprise/Apprise.pyi:8: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- apprise/Apprise.pyi:11: error: Name "Union" is not defined  [name-defined]
- apprise/Apprise.pyi:11: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Union")
- apprise/Apprise.pyi:16: error: Variable "apprise.Apprise._Servers" is not valid as a type  [valid-type]
- apprise/Apprise.pyi:16: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- apprise/Apprise.pyi:17: error: Module "apprise.AppriseAsset" is not valid as a type  [valid-type]
- apprise/Apprise.pyi:17: note: Perhaps you meant to use a protocol matching the module structure?
- apprise/Apprise.pyi:23: error: Name "Union" is not defined  [name-defined]
- apprise/Apprise.pyi:23: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Union")

... (truncated 325 lines) ...

poetry (https://github.com/python-poetry/poetry)
+ Traceback (most recent call last):
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
+     sys.exit(console_entry())
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
+     main()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 95, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 174, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 194, in build
+     result = _build(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 277, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2870, in dispatch
+     graph = load_graph(sources, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 3055, in load_graph
+     st = State(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2007, in __init__
+     self.compute_dependencies()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2296, in compute_dependencies
+     dep_entries = manager.all_imported_modules_in_file(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 811, in all_imported_modules_in_file
+     if self.is_module(sub_id):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 838, in is_module
+     return find_module_simple(id, self) is not None
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2719, in find_module_simple
+     x = find_module_with_reason(id, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2728, in find_module_with_reason
+     x = manager.find_module_cache.find_module(id)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 308, in find_module
+     self.results[id] = self._find_module(id, use_typeshed)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 434, in _find_module
+     if fscache.isdir(stub_dir) and self._is_compatible_stub_package(stub_dir):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 579, in _is_compatible_stub_package
+     with open(metadata_fnam, "rb", encoding="locale") as f:
+ ValueError: binary mode doesn't take an encoding argument
- Warning: unused section(s) in pyproject.toml: module = ['xattr.*']
- src/poetry/vcs/git/system.py:8: error: Cannot find implementation or library stub for module named "dulwich.client"  [import]
- src/poetry/utils/setup_reader.py:9: error: Cannot find implementation or library stub for module named "poetry.core.constraints.version"  [import]
- src/poetry/utils/extras.py:11: error: Cannot find implementation or library stub for module named "packaging.utils"  [import]
- src/poetry/utils/extras.py:12: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/utils/_compat.py:13: error: Cannot find implementation or library stub for module named "tomli"  [import]
- src/poetry/repositories/abstract_repository.py:9: error: Cannot find implementation or library stub for module named "poetry.core.constraints.version"  [import]
- src/poetry/repositories/abstract_repository.py:10: error: Cannot find implementation or library stub for module named "poetry.core.packages.dependency"  [import]
- src/poetry/repositories/abstract_repository.py:11: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/packages/dependency_package.py:7: error: Cannot find implementation or library stub for module named "poetry.core.packages.dependency"  [import]
- src/poetry/packages/dependency_package.py:8: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/mixology/result.py:7: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/mixology/result.py:8: error: Cannot find implementation or library stub for module named "poetry.core.packages.project_package"  [import]
- src/poetry/masonry/api.py:3: error: Cannot find implementation or library stub for module named "poetry.core.masonry.api"  [import]
- src/poetry/layouts/layout.py:7: error: Cannot find implementation or library stub for module named "packaging.utils"  [import]
- src/poetry/layouts/layout.py:8: error: Cannot find implementation or library stub for module named "poetry.core.pyproject.toml"  [import]
- src/poetry/layouts/layout.py:9: error: Cannot find implementation or library stub for module named "poetry.core.utils.helpers"  [import]
- src/poetry/layouts/layout.py:10: error: Cannot find implementation or library stub for module named "tomlkit"  [import]
- src/poetry/layouts/layout.py:13: error: Cannot find implementation or library stub for module named "tomlkit.toml_document"  [import]
- src/poetry/layouts/layout.py:19: error: Cannot find implementation or library stub for module named "tomlkit.items"  [import]
- src/poetry/layouts/layout.py:93: error: Unused "type: ignore" comment
- src/poetry/layouts/layout.py:96: error: Unused "type: ignore" comment
- src/poetry/installation/base_installer.py:7: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/installation/operations/operation.py:8: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/console/exceptions.py:3: error: Cannot find implementation or library stub for module named "cleo.exceptions"  [import]
- src/poetry/console/exceptions.py:6: error: Class cannot subclass "CleoError" (has type "Any")  [misc]
- src/poetry/console/command_loader.py:5: error: Cannot find implementation or library stub for module named "cleo.exceptions"  [import]
- src/poetry/console/command_loader.py:6: error: Cannot find implementation or library stub for module named "cleo.loaders.factory_command_loader"  [import]
- src/poetry/console/command_loader.py:12: error: Cannot find implementation or library stub for module named "cleo.commands.command"  [import]
- src/poetry/console/command_loader.py:15: error: Class cannot subclass "FactoryCommandLoader" (has type "Any")  [misc]
- src/poetry/console/io/inputs/run_argv_input.py:5: error: Cannot find implementation or library stub for module named "cleo.io.inputs.argv_input"  [import]
- src/poetry/console/io/inputs/run_argv_input.py:9: error: Cannot find implementation or library stub for module named "cleo.io.inputs.definition"  [import]
- src/poetry/console/io/inputs/run_argv_input.py:12: error: Class cannot subclass "ArgvInput" (has type "Any")  [misc]
- src/poetry/locations.py:9: error: Cannot find implementation or library stub for module named "platformdirs"  [import]
- src/poetry/locations.py:55: error: Returning Any from function declared to return "Path"  [no-any-return]
- src/poetry/utils/source.py:7: error: Cannot find implementation or library stub for module named "tomlkit.items"  [import]
- src/poetry/utils/source.py:13: error: Cannot find implementation or library stub for module named "tomlkit"  [import]
- src/poetry/repositories/repository.py:7: error: Cannot find implementation or library stub for module named "packaging.utils"  [import]
- src/poetry/repositories/repository.py:8: error: Cannot find implementation or library stub for module named "poetry.core.constraints.version"  [import]
- src/poetry/repositories/repository.py:17: error: Cannot find implementation or library stub for module named "poetry.core.packages.dependency"  [import]
- src/poetry/repositories/repository.py:18: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/repositories/repository.py:19: error: Cannot find implementation or library stub for module named "poetry.core.packages.utils.link"  [import]
- src/poetry/repositories/link_sources/base.py:10: error: Cannot find implementation or library stub for module named "poetry.core.constraints.version"  [import]
- src/poetry/repositories/link_sources/base.py:11: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/repositories/link_sources/base.py:12: error: Cannot find implementation or library stub for module named "poetry.core.version.exceptions"  [import]
- src/poetry/repositories/link_sources/base.py:22: error: Cannot find implementation or library stub for module named "packaging.utils"  [import]
- src/poetry/repositories/link_sources/base.py:23: error: Cannot find implementation or library stub for module named "poetry.core.packages.utils.link"  [import]
- src/poetry/packages/package_collection.py:12: error: Cannot find implementation or library stub for module named "poetry.core.packages.dependency"  [import]
- src/poetry/packages/package_collection.py:13: error: Cannot find implementation or library stub for module named "poetry.core.packages.package"  [import]
- src/poetry/mixology/term.py:11: error: Cannot find implementation or library stub for module named "poetry.core.constraints.version"  [import]
- src/poetry/mixology/term.py:12: error: Cannot find implementation or library stub for module named "poetry.core.packages.dependency"  [import]

... (truncated 317 lines) ...

dulwich (https://github.com/dulwich/dulwich)
- dulwich/graph.py:47: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- dulwich/pack.py:201: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- dulwich/diff_tree.py:264: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- dulwich/diff_tree.py:310: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- dulwich/object_store.py:1213: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- dulwich/server.py:1084: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- dulwich/contrib/requests_vendor.py:34: error: Library stubs not installed for "requests"  [import]
- dulwich/contrib/requests_vendor.py:34: note: Hint: "python3 -m pip install types-requests"
- dulwich/contrib/requests_vendor.py:34: note: (or run "mypy --install-types" to install all missing stub packages)
- dulwich/contrib/requests_vendor.py:34: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ Traceback (most recent call last):
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
+     sys.exit(console_entry())
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
+     main()
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 95, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 174, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 194, in build
+     result = _build(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 277, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2870, in dispatch
+     graph = load_graph(sources, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 3137, in load_graph
+     newst = State(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1934, in __init__
+     path, follow_imports = find_module_and_diagnose(
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2624, in find_module_and_diagnose
+     result = find_module_with_reason(id, manager)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2728, in find_module_with_reason
+     x = manager.find_module_cache.find_module(id)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 308, in find_module
+     self.results[id] = self._find_module(id, use_typeshed)
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 434, in _find_module
+     if fscache.isdir(stub_dir) and self._is_compatible_stub_package(stub_dir):
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/modulefinder.py", line 579, in _is_compatible_stub_package
+     with open(metadata_fnam, "rb", encoding="locale") as f:
+ ValueError: binary mode doesn't take an encoding argument


... (truncated 3154 lines) ...```

github-actions[bot] avatar Feb 11 '23 03:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 11 '23 18:02 github-actions[bot]

Would it be appropriate to use "utf-8" instead of "locale" (which isn't added until 3.10)?

In my opinion, "utf-8" almost always the best way to go. It provides more consistency across platforms. Only if the old behavior is truly needed (non-utf8 on Windows platforms) would you likely want "locale".

jaraco avatar Jun 23 '23 18:06 jaraco