diff --git a/3rdparty/python/mypy-requirements.txt b/3rdparty/python/mypy-requirements.txt index d35cc6333c7..c918ed96a08 100644 --- a/3rdparty/python/mypy-requirements.txt +++ b/3rdparty/python/mypy-requirements.txt @@ -1,3 +1,3 @@ -mypy==1.1.1 +mypy==1.10.1 mypy-typing-asserts -strawberry-graphql==0.159.1 +strawberry-graphql==0.240.4 diff --git a/3rdparty/python/mypy.lock b/3rdparty/python/mypy.lock index c6f688b210b..6668e69876c 100644 --- a/3rdparty/python/mypy.lock +++ b/3rdparty/python/mypy.lock @@ -10,8 +10,8 @@ // ], // "generated_with_requirements": [ // "mypy-typing-asserts", -// "mypy==1.1.1", -// "strawberry-graphql==0.159.1" +// "mypy==1.10.1", +// "strawberry-graphql==0.240.4" // ], // "manylinux": "manylinux2014", // "requirement_constraints": [], @@ -26,6 +26,7 @@ "allow_wheels": true, "build_isolation": true, "constraints": [], + "excluded": [], "locked_resolves": [ { "locked_requirements": [ @@ -33,13 +34,13 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "5766780452bd5ec8ba133f8bf287dc92713e3868ddd83aee4faab9fc3e303dc3", - "url": "https://files.pythonhosted.org/packages/f8/39/e5143e7ec70939d2076c1165ae9d4a3815597019c4d797b7f959cf778600/graphql_core-3.2.3-py3-none-any.whl" + "hash": "1604f2042edc5f3114f49cac9d77e25863be51b23a54a61a23245cf32f6476f0", + "url": "https://files.pythonhosted.org/packages/d1/33/cc72c4c658c6316f188a60bc4e5a91cd4ceaaa8c3e7e691ac9297e4e72c7/graphql_core-3.2.4-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "06d2aad0ac723e35b1cb47885d3e5c45e956a53bc1b209a9fc5369007fe46676", - "url": "https://files.pythonhosted.org/packages/ee/a6/94df9045ca1bac404c7b394094cd06713f63f49c7a4d54d99b773ae81737/graphql-core-3.2.3.tar.gz" + "hash": "acbe2e800980d0e39b4685dd058c2f4042660b89ebca38af83020fd872ff1264", + "url": "https://files.pythonhosted.org/packages/66/9e/aa527fb09a9d7399d5d7d2aa2da490e4580707652d3b4fc156996ae88a5b/graphql-core-3.2.4.tar.gz" } ], "project_name": "graphql-core", @@ -47,39 +48,39 @@ "typing-extensions<5,>=4.2; python_version < \"3.8\"" ], "requires_python": "<4,>=3.6", - "version": "3.2.3" + "version": "3.2.4" }, { "artifacts": [ { "algorithm": "sha256", - "hash": "4e4e8b362cdf99ba00c2b218036002bdcdf1e0de085cdb296a49df03fb31dfc4", - "url": "https://files.pythonhosted.org/packages/a4/0b/3a30f50287e42a4230320fa2eac25eb3017d38a7c31f083d407ab627607c/mypy-1.1.1-py3-none-any.whl" + "hash": "71d8ac0b906354ebda8ef1673e5fde785936ac1f29ff6987c7483cfbd5a4235a", + "url": "https://files.pythonhosted.org/packages/2b/ee/d53a3d4792a09b6cd757978951d6dcf8b10825a8b8522b68e9b5eb53b9a1/mypy-1.10.1-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "9401e33814cec6aec8c03a9548e9385e0e228fc1b8b0a37b9ea21038e64cdd8a", - "url": "https://files.pythonhosted.org/packages/30/da/808ceaf2bcf23a9e90156c7b11b41add8dd5a009ee48159ec820d04d97bd/mypy-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" + "hash": "c2ae450d60d7d020d67ab440c6e3fae375809988119817214440033f26ddf7bf", + "url": "https://files.pythonhosted.org/packages/33/b0/20c9f6dcbfb312d1804a81f4a39e0b401fe614dc0de580249b6deb07d053/mypy-1.10.1-cp39-cp39-macosx_11_0_arm64.whl" }, { "algorithm": "sha256", - "hash": "59bbd71e5c58eed2e992ce6523180e03c221dcd92b52f0e792f291d67b15a71c", - "url": "https://files.pythonhosted.org/packages/47/9f/34f6a2254f7d39b8c4349b8ac480c233d37c377faf2c67c6ef925b3af0ab/mypy-1.1.1-cp39-cp39-macosx_11_0_arm64.whl" + "hash": "fe85ed6836165d52ae8b88f99527d3d1b2362e0cb90b005409b8bed90e9059b3", + "url": "https://files.pythonhosted.org/packages/50/00/86bb2f6c5b58fc6f360dd4cb5c0666dc67c05007c2cddcc694528a59a604/mypy-1.10.1-cp39-cp39-macosx_10_9_x86_64.whl" }, { "algorithm": "sha256", - "hash": "ae9ceae0f5b9059f33dbc62dea087e942c0ccab4b7a003719cb70f9b8abfa32f", - "url": "https://files.pythonhosted.org/packages/62/54/be80f8d01f5cf72f774a77f9f750527a6fa733f09f78b1da30e8fa3914e6/mypy-1.1.1.tar.gz" + "hash": "6be84c06e6abd72f960ba9a71561c14137a583093ffcf9bbfaf5e613d63fa531", + "url": "https://files.pythonhosted.org/packages/aa/87/ec65c45b2e5160203a680b0f79e459fbe9c192f9eff501c3fec82bef3be5/mypy-1.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" }, { "algorithm": "sha256", - "hash": "19ba15f9627a5723e522d007fe708007bae52b93faab00f95d72f03e1afa9598", - "url": "https://files.pythonhosted.org/packages/b8/72/385f3aeaaf262325454ac7f569eb81ac623464871df23d9778c864d04c6c/mypy-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl" + "hash": "2189ff1e39db399f08205e22a797383613ce1cb0cb3b13d8bcf0170e45b96cc3", + "url": "https://files.pythonhosted.org/packages/c5/5c/f61c876647036d572a1434f0251257a04f2a7bd038c718b28fa5ca699515/mypy-1.10.1-cp39-cp39-musllinux_1_1_x86_64.whl" }, { "algorithm": "sha256", - "hash": "4b398d8b1f4fba0e3c6463e02f8ad3346f71956b92287af22c9b12c3ec965a9f", - "url": "https://files.pythonhosted.org/packages/be/d5/5588a2ee0d77189626a57b555b6b006dda6d5b0083f16c6be0c2d761cd7b/mypy-1.1.1-cp39-cp39-musllinux_1_1_x86_64.whl" + "hash": "1f8f492d7db9e3593ef42d4f115f04e556130f2819ad33ab84551403e97dd4c0", + "url": "https://files.pythonhosted.org/packages/c7/b9/81e4c6dbb1ec1e72503de3ff2c5fe4b7f224e04613b670f8b9004cd8a4dd/mypy-1.10.1.tar.gz" } ], "project_name": "mypy", @@ -88,13 +89,12 @@ "mypy-extensions>=1.0.0", "pip; extra == \"install-types\"", "psutil>=4.0; extra == \"dmypy\"", + "setuptools>=50; extra == \"mypyc\"", "tomli>=1.1.0; python_version < \"3.11\"", - "typed-ast<2,>=1.4.0; extra == \"python2\"", - "typed-ast<2,>=1.4.0; python_version < \"3.8\"", - "typing-extensions>=3.10" + "typing-extensions>=4.1.0" ], - "requires_python": ">=3.7", - "version": "1.1.1" + "requires_python": ">=3.8", + "version": "1.10.1" }, { "artifacts": [ @@ -174,13 +174,13 @@ "artifacts": [ { "algorithm": "sha256", - "hash": "f16c3efcb3b33e8f35ddbbe640e61e67efeeeb05d313416ae10336b8d2c7a69b", - "url": "https://files.pythonhosted.org/packages/a2/cf/abbb0f44c059f61a562d386e79d1b8adb4def370a6e99f26033002caf2e2/strawberry_graphql-0.159.1-py3-none-any.whl" + "hash": "ebedacbf943463b222e15e628142fbf9121ef89a7c31176271f5a3ea2491fa4c", + "url": "https://files.pythonhosted.org/packages/4d/4c/fb5783b2bb45e614712d30bce2b771e6ef41c0e91cc4805d033c77033c38/strawberry_graphql-0.240.4-py3-none-any.whl" }, { "algorithm": "sha256", - "hash": "25b56e294ed032e69c066fe0ac802a724f4364c2d70d903e6a9b41d8c62f5add", - "url": "https://files.pythonhosted.org/packages/2b/49/90df8aca12c7e213ccb70712391b19b5bdc0607bef3ced15e2664acac0f2/strawberry_graphql-0.159.1.tar.gz" + "hash": "50c6436e02b3028b6fdcdd62e2756f7c5ec9a92f0dfc5ecf7fba00a6ce280eeb", + "url": "https://files.pythonhosted.org/packages/ab/0b/6b3504a9b5a9fdcc3ab3fee67741ae26c8494f02d7d8cbe57ec526ac8915/strawberry_graphql-0.240.4.tar.gz" } ], "project_name": "strawberry-graphql", @@ -188,28 +188,32 @@ "Django>=3.2; extra == \"django\"", "aiohttp<4.0.0,>=3.7.4.post0; extra == \"aiohttp\"", "asgiref<4.0,>=3.2; extra == \"django\" or extra == \"channels\"", - "backports.cached-property<2.0.0,>=1.0.2; python_version < \"3.8\"", + "astunparse<2.0.0,>=1.6.3; python_version < \"3.9\"", "chalice<2.0,>=1.22; extra == \"chalice\"", "channels>=3.0.5; extra == \"channels\"", - "click<9.0,>=7.0; extra == \"debug-server\" or extra == \"cli\"", "fastapi>=0.65.2; extra == \"fastapi\"", "flask>=1.1; extra == \"flask\"", - "graphql-core<3.3.0,>=3.2.0", + "graphlib_backport; python_version < \"3.9\" and extra == \"cli\"", + "graphql-core<3.4.0,>=3.2.0", "libcst>=0.4.7; extra == \"debug\" or extra == \"debug-server\" or extra == \"cli\"", + "litestar>=2; python_version >= \"3.8\" and extra == \"litestar\"", "opentelemetry-api<2; extra == \"opentelemetry\"", "opentelemetry-sdk<2; extra == \"opentelemetry\"", - "pydantic<2; extra == \"pydantic\"", + "pydantic>1.6.1; extra == \"pydantic\"", "pygments<3.0,>=2.3; extra == \"debug-server\" or extra == \"cli\"", + "pyinstrument>=4.0.0; extra == \"pyinstrument\"", "python-dateutil<3.0.0,>=2.7.0", - "python-multipart<0.0.6,>=0.0.5; extra == \"asgi\" or extra == \"debug-server\" or extra == \"fastapi\"", + "python-multipart>=0.0.7; extra == \"asgi\" or extra == \"debug-server\" or extra == \"fastapi\"", + "quart>=0.19.3; extra == \"quart\"", "rich>=12.0.0; extra == \"debug\" or extra == \"debug-server\" or extra == \"cli\"", "sanic>=20.12.2; extra == \"sanic\"", - "starlette>=0.13.6; extra == \"asgi\" or extra == \"debug-server\"", - "typing_extensions<5.0.0,>=3.7.4", - "uvicorn<0.21.0,>=0.11.6; extra == \"debug-server\"" + "starlette>=0.18.0; extra == \"asgi\" or extra == \"debug-server\"", + "typer>=0.7.0; extra == \"debug-server\" or extra == \"cli\"", + "typing-extensions>=4.5.0", + "uvicorn>=0.11.6; extra == \"debug-server\"" ], - "requires_python": "<4.0,>=3.7", - "version": "0.159.1" + "requires_python": "<4.0,>=3.8", + "version": "0.240.4" }, { "artifacts": [ @@ -253,14 +257,15 @@ ], "only_builds": [], "only_wheels": [], + "overridden": [], "path_mappings": {}, - "pex_version": "2.3.1", - "pip_version": "24.0", + "pex_version": "2.16.2", + "pip_version": "24.2", "prefer_older_binary": false, "requirements": [ "mypy-typing-asserts", - "mypy==1.1.1", - "strawberry-graphql==0.159.1" + "mypy==1.10.1", + "strawberry-graphql==0.240.4" ], "requires_python": [ "==3.9.*" diff --git a/pants-plugins/pants_explorer/server/graphql/query/targets.py b/pants-plugins/pants_explorer/server/graphql/query/targets.py index 2a8687bfad2..9f3d4b5634d 100644 --- a/pants-plugins/pants_explorer/server/graphql/query/targets.py +++ b/pants-plugins/pants_explorer/server/graphql/query/targets.py @@ -78,7 +78,7 @@ def from_data(cls, data: TargetData) -> Target: address = json.pop("address") target_type = json.pop("target_type") fields = json - return cls(address=address, target_type=target_type, fields=fields) + return cls(address=address, target_type=target_type, fields=fields) # type: ignore[call-arg] @strawberry.input( diff --git a/src/python/pants/backend/go/util_rules/coverage_profile_test.py b/src/python/pants/backend/go/util_rules/coverage_profile_test.py index 49ac707e210..3668f29873e 100644 --- a/src/python/pants/backend/go/util_rules/coverage_profile_test.py +++ b/src/python/pants/backend/go/util_rules/coverage_profile_test.py @@ -296,7 +296,7 @@ class ProfileTestCase: ] -@pytest.mark.parametrize("case", _TEST_CASES, ids=lambda c: c.name) # type: ignore[no-any-return] +@pytest.mark.parametrize("case", _TEST_CASES, ids=lambda c: c.name) def test_parse_go_coverage_profiles(case) -> None: try: profiles = parse_go_coverage_profiles(case.input.encode(), description_of_origin="test") diff --git a/src/python/pants/backend/nfpm/util_rules/sandbox.py b/src/python/pants/backend/nfpm/util_rules/sandbox.py index 0287c8be46b..95c9098bd64 100644 --- a/src/python/pants/backend/nfpm/util_rules/sandbox.py +++ b/src/python/pants/backend/nfpm/util_rules/sandbox.py @@ -208,7 +208,11 @@ async def populate_nfpm_content_sandbox( ): for entry in digest_entries: if isinstance(entry, FileEntry) and entry.path == source.value: - moved_entries.append(dataclasses.replace(entry, path=src.value)) + new_path = src.value + if new_path is None: + raise ValueError("unexpected None") + + moved_entries.append(dataclasses.replace(entry, path=new_path)) else: moved_entries.append(entry) diff --git a/src/python/pants/backend/python/macros/common_requirements_rule.py b/src/python/pants/backend/python/macros/common_requirements_rule.py index 5ccb23cd3b5..a657d7e6831 100644 --- a/src/python/pants/backend/python/macros/common_requirements_rule.py +++ b/src/python/pants/backend/python/macros/common_requirements_rule.py @@ -128,7 +128,7 @@ def generate_tgt( normalized_proj_name = canonicalize_project_name(project_name) tgt_overrides = overrides.pop(normalized_proj_name, {}) if Dependencies.alias in tgt_overrides: - tgt_overrides = tgt_overrides | { + tgt_overrides = tgt_overrides | { # type: ignore[operator] Dependencies.alias: list(tgt_overrides[Dependencies.alias]) + req_deps } diff --git a/src/python/pants/backend/python/packaging/pyoxidizer/rules.py b/src/python/pants/backend/python/packaging/pyoxidizer/rules.py index c979d55c7fb..dd3f4cf6ae1 100644 --- a/src/python/pants/backend/python/packaging/pyoxidizer/rules.py +++ b/src/python/pants/backend/python/packaging/pyoxidizer/rules.py @@ -56,6 +56,7 @@ ) from pants.engine.unions import UnionRule from pants.util.docutil import doc_url +from pants.util.frozendict import FrozenDict from pants.util.logging import LogLevel from pants.util.strutil import softwrap @@ -188,10 +189,12 @@ async def package_pyoxidizer_binary( process_with_caching = dataclasses.replace( pex_process, argv=(bash.path, runner_script.path, *pex_process.argv), - append_only_caches={ - **pex_process.append_only_caches, - "pyoxidizer": runner_script.CACHE_PATH, - }, + append_only_caches=FrozenDict( + { + **pex_process.append_only_caches, + "pyoxidizer": runner_script.CACHE_PATH, + } + ), ) result = await Get(ProcessResult, Process, process_with_caching) diff --git a/src/python/pants/backend/python/util_rules/lockfile_metadata.py b/src/python/pants/backend/python/util_rules/lockfile_metadata.py index e24132d39cd..ee433738aaa 100644 --- a/src/python/pants/backend/python/util_rules/lockfile_metadata.py +++ b/src/python/pants/backend/python/util_rules/lockfile_metadata.py @@ -229,7 +229,7 @@ def _from_json_dict( ) -> PythonLockfileMetadataV3: v2_metadata = super()._from_json_dict(json_dict, lockfile_description, error_suffix) metadata = _get_metadata(json_dict, lockfile_description, error_suffix) - manylinux = metadata("manylinux", str, lambda l: l) # type: ignore[no-any-return] + manylinux = metadata("manylinux", str, lambda l: l) requirement_constraints = metadata( "requirement_constraints", Set[PipRequirement], diff --git a/src/python/pants/backend/python/util_rules/pex_cli.py b/src/python/pants/backend/python/util_rules/pex_cli.py index b83c53d1acf..6dcfdbbf293 100644 --- a/src/python/pants/backend/python/util_rules/pex_cli.py +++ b/src/python/pants/backend/python/util_rules/pex_cli.py @@ -205,7 +205,7 @@ async def setup_pex_cli_process( env = { **complete_pex_env.environment_dict(python=bootstrap_python), **python_native_code.subprocess_env_vars, - **(request.extra_env or {}), + **(request.extra_env or {}), # type: ignore[dict-item] # If a subcommand is used, we need to use the `pex3` console script. **({"PEX_SCRIPT": "pex3"} if request.subcommand else {}), } diff --git a/src/python/pants/backend/shell/util_rules/shell_command.py b/src/python/pants/backend/shell/util_rules/shell_command.py index 08f2390da81..be702cced6d 100644 --- a/src/python/pants/backend/shell/util_rules/shell_command.py +++ b/src/python/pants/backend/shell/util_rules/shell_command.py @@ -156,7 +156,7 @@ async def _prepare_process_request_from_target( append_only_caches = { **merged_extras.append_only_caches, - **(shell_command.get(ShellCommandNamedCachesField).value or {}), + **(shell_command.get(ShellCommandNamedCachesField).value or {}), # type: ignore[dict-item] } cache_scope = env_target.default_cache_scope diff --git a/src/python/pants/backend/terraform/hcl2_parser.py b/src/python/pants/backend/terraform/hcl2_parser.py index 88d203881de..06dd38bb789 100644 --- a/src/python/pants/backend/terraform/hcl2_parser.py +++ b/src/python/pants/backend/terraform/hcl2_parser.py @@ -30,7 +30,7 @@ def resolve_pure_path(base: PurePath, relative_path: PurePath) -> PurePath: def extract_module_source_paths(path: PurePath, raw_content: bytes) -> Set[str]: # Import here so we can still test this file with pytest (since `hcl2` is not present in # normal Pants venv.) - import hcl2 # type: ignore[import] # pants: no-infer-dep + import hcl2 # type: ignore[import-not-found] # pants: no-infer-dep content = raw_content.decode("utf-8") parsed_content = hcl2.loads(content) diff --git a/src/python/pants/bsp/protocol.py b/src/python/pants/bsp/protocol.py index a7b1a1f9627..54858c551fc 100644 --- a/src/python/pants/bsp/protocol.py +++ b/src/python/pants/bsp/protocol.py @@ -6,13 +6,16 @@ from concurrent.futures import Future from typing import Any, BinaryIO, ClassVar, Protocol -from pylsp_jsonrpc.endpoint import Endpoint # type: ignore[import] -from pylsp_jsonrpc.exceptions import ( # type: ignore[import] +from pylsp_jsonrpc.endpoint import Endpoint # type: ignore[import-untyped] +from pylsp_jsonrpc.exceptions import ( # type: ignore[import-untyped] JsonRpcException, JsonRpcInvalidRequest, JsonRpcMethodNotFound, ) -from pylsp_jsonrpc.streams import JsonRpcStreamReader, JsonRpcStreamWriter # type: ignore[import] +from pylsp_jsonrpc.streams import ( # type: ignore[import-untyped] + JsonRpcStreamReader, + JsonRpcStreamWriter, +) from pants.bsp.context import BSPContext from pants.bsp.spec.notification import BSPNotification diff --git a/src/python/pants/bsp/protocol_test.py b/src/python/pants/bsp/protocol_test.py index 2d46033345c..ef1f92648ac 100644 --- a/src/python/pants/bsp/protocol_test.py +++ b/src/python/pants/bsp/protocol_test.py @@ -7,7 +7,7 @@ from urllib.parse import urlparse import pytest -from pylsp_jsonrpc.exceptions import JsonRpcException # type: ignore[import] +from pylsp_jsonrpc.exceptions import JsonRpcException # type: ignore[import-untyped] from internal_plugins.test_lockfile_fixtures.lockfile_fixture import ( JVMLockfileFixture, diff --git a/src/python/pants/bsp/testutil.py b/src/python/pants/bsp/testutil.py index f974ddedf58..84bbc585694 100644 --- a/src/python/pants/bsp/testutil.py +++ b/src/python/pants/bsp/testutil.py @@ -10,8 +10,11 @@ from threading import Thread from typing import Any, BinaryIO, Dict, Iterable, Tuple -from pylsp_jsonrpc.endpoint import Endpoint # type: ignore[import] -from pylsp_jsonrpc.streams import JsonRpcStreamReader, JsonRpcStreamWriter # type: ignore[import] +from pylsp_jsonrpc.endpoint import Endpoint # type: ignore[import-untyped] +from pylsp_jsonrpc.streams import ( # type: ignore[import-untyped] + JsonRpcStreamReader, + JsonRpcStreamWriter, +) from pants.bsp.context import BSPContext from pants.bsp.protocol import BSPConnection diff --git a/src/python/pants/core/goals/multi_tool_goal_helper.py b/src/python/pants/core/goals/multi_tool_goal_helper.py index 5f6ff8ebb85..75dcfc9e808 100644 --- a/src/python/pants/core/goals/multi_tool_goal_helper.py +++ b/src/python/pants/core/goals/multi_tool_goal_helper.py @@ -25,7 +25,7 @@ class OnlyOption(StrListOption): def __new__(cls, tool_description: str, example1: str, example2: str): return super().__new__( - cls, # type: ignore[arg-type] + cls, "--only", help=lambda cls: softwrap( f""" @@ -47,10 +47,10 @@ class BatchSizeOption(IntOption): def __new__(cls, uppercase: str, lowercase: str): return super().__new__( - cls, # type: ignore[arg-type] + cls, "--batch-size", advanced=True, - default=128, # type: ignore[arg-type] + default=128, help=softwrap( f""" The target number of files to be included in each {lowercase} batch. diff --git a/src/python/pants/core/goals/tailor.py b/src/python/pants/core/goals/tailor.py index 5af800036ad..ffa6e3900b3 100644 --- a/src/python/pants/core/goals/tailor.py +++ b/src/python/pants/core/goals/tailor.py @@ -226,7 +226,7 @@ def restrict_sources(self) -> PutativeTarget: return dataclasses.replace( self, owned_sources=owned_sources, - kwargs={**self.kwargs, "sources": owned_sources}, + kwargs=FrozenDict({**self.kwargs, "sources": owned_sources}), ) def add_comments(self, comments: Iterable[str]) -> PutativeTarget: @@ -246,7 +246,7 @@ def fmt_val(v) -> str: if self.kwargs or has_name: _kwargs = { **({"name": self.name} if has_name else {}), - **self.kwargs, # type: ignore[arg-type] + **self.kwargs, } _kwargs_str_parts = [f"\n{indent}{k}={fmt_val(v)}" for k, v in _kwargs.items()] kwargs_str = ",".join(_kwargs_str_parts) + ",\n" diff --git a/src/python/pants/core/goals/test.py b/src/python/pants/core/goals/test.py index 8c9695f9c57..d8ed1848951 100644 --- a/src/python/pants/core/goals/test.py +++ b/src/python/pants/core/goals/test.py @@ -1013,7 +1013,7 @@ async def run_tests( } coverage_collections = [] for data_cls, data in itertools.groupby(all_coverage_data, lambda data: type(data)): - collection_cls = coverage_types_to_collection_types[data_cls] + collection_cls = coverage_types_to_collection_types[data_cls] # type: ignore[index] coverage_collections.append(collection_cls(data)) # We can create multiple reports for each coverage data (e.g., console, xml, html) coverage_reports_collections = await MultiGet( diff --git a/src/python/pants/core/util_rules/adhoc_process_support.py b/src/python/pants/core/util_rules/adhoc_process_support.py index affabdbb147..e4688e00dc0 100644 --- a/src/python/pants/core/util_rules/adhoc_process_support.py +++ b/src/python/pants/core/util_rules/adhoc_process_support.py @@ -454,7 +454,7 @@ async def create_tool_runner( append_only_caches = { **merged_extras.append_only_caches, - **(request.named_caches or {}), + **(request.named_caches or {}), # type: ignore[dict-item] } return ToolRunner( diff --git a/src/python/pants/core/util_rules/unowned_dependency_behavior.py b/src/python/pants/core/util_rules/unowned_dependency_behavior.py index 84c5b6af1e5..0890beb3f45 100644 --- a/src/python/pants/core/util_rules/unowned_dependency_behavior.py +++ b/src/python/pants/core/util_rules/unowned_dependency_behavior.py @@ -19,7 +19,7 @@ class UnownedDependencyUsage(Enum): class UnownedDependencyUsageOption(EnumOption[UnownedDependencyUsage, UnownedDependencyUsage]): def __new__(cls, example_runtime_issue: str, how_to_ignore: str): return super().__new__( - cls, # type: ignore[arg-type] # Expects the base class due to super + cls, default=UnownedDependencyUsage.LogWarning, help=softwrap( f""" diff --git a/src/python/pants/engine/goal.py b/src/python/pants/engine/goal.py index 128ccfb4bf2..0ff5acb6398 100644 --- a/src/python/pants/engine/goal.py +++ b/src/python/pants/engine/goal.py @@ -142,7 +142,7 @@ def output(self, console: Console) -> Iterator[Callable[[str], None]]: The passed options instance will generally be the `Goal.Options` of an `Outputting` `Goal`. """ with self.output_sink(console) as output_sink: - yield lambda msg: output_sink.write(msg) # type: ignore[no-any-return] + yield lambda msg: output_sink.write(msg) @final @contextmanager diff --git a/src/python/pants/engine/internals/build_files_test.py b/src/python/pants/engine/internals/build_files_test.py index 741c2825664..24178970dfa 100644 --- a/src/python/pants/engine/internals/build_files_test.py +++ b/src/python/pants/engine/internals/build_files_test.py @@ -672,7 +672,7 @@ def _determenistic_parametrize_group_keys(value: Mapping[str, Any]) -> dict[str, ) == _determenistic_parametrize_group_keys( dict( description="desc for a and b", - **Parametrize("a", tags=["opt-a"], resolve="lock-a"), # type: ignore[arg-type] + **Parametrize("a", tags=["opt-a"], resolve="lock-a"), **Parametrize("b", tags=["opt-b"], resolve="lock-b"), ) ) diff --git a/src/python/pants/engine/internals/defaults_test.py b/src/python/pants/engine/internals/defaults_test.py index 33c99fd384a..349a9344f32 100644 --- a/src/python/pants/engine/internals/defaults_test.py +++ b/src/python/pants/engine/internals/defaults_test.py @@ -279,9 +279,7 @@ def _determenistic_parametrize_group_keys(value: Mapping[str, Any]) -> dict[str, kwargs=dict(ignore_unknown_fields=True), expected_defaults={ "test_type_1": _determenistic_parametrize_group_keys( - { - **ParametrizeDefault("splat", description="splat-desc") # type: ignore[list-item] - } + {**ParametrizeDefault("splat", description="splat-desc")} ) }, ), diff --git a/src/python/pants/engine/internals/parametrize_test.py b/src/python/pants/engine/internals/parametrize_test.py index 9a40f62a6be..093ec1e1baa 100644 --- a/src/python/pants/engine/internals/parametrize_test.py +++ b/src/python/pants/engine/internals/parametrize_test.py @@ -122,7 +122,7 @@ def test_bad_group_name(exception_str: str, args: list[Any], kwargs: dict[str, A dict( # Field overridden by some parametrize groups. f="x", - **Parametrize("A", f=1), # type: ignore[arg-type] + **Parametrize("A", f=1), **Parametrize("B", f=2), **Parametrize("C", g=[]), ), @@ -134,9 +134,9 @@ def test_bad_group_name(exception_str: str, args: list[Any], kwargs: dict[str, A ("a@c=val2,parametrize=root-sub2", {"a": 2, "b": 0, "c": "val2"}), ("a@parametrize=root-sub1", {"a": 1, "b": 1}), ], - dict( # type: ignore[arg-type] + dict( b=0, - **Parametrize( # type: ignore[arg-type] + **Parametrize( "root", a=1, **Parametrize("sub1", b=1), @@ -176,7 +176,7 @@ def test_expand( dict( g="1", i="1", - **Parametrize("A", f="1", g="2"), # type: ignore[arg-type] + **Parametrize("A", f="1", g="2"), **Parametrize("B"), ), ), @@ -219,7 +219,7 @@ def test_expand_existing_parameters( h=Parametrize("x", "y"), x=5, z=6, - **Parametrize("A", f=1), # type: ignore[arg-type] + **Parametrize("A", f=1), **Parametrize("B", g=2, x=3), ), "Failed to parametrize `a:a`:\n Conflicting parametrizations for fields: 'f', 'g'", @@ -233,7 +233,7 @@ def test_expand_existing_parameters( z=6, **Parametrize( "root", - **Parametrize("A", f=1, h=4), # type: ignore[arg-type] + **Parametrize("A", f=1, h=4), **Parametrize("B", g=2, x=3), ), ), @@ -243,7 +243,7 @@ def test_expand_existing_parameters( ( dict( f="x", - **Parametrize("A", a=1, b=3), # type: ignore[arg-type] + **Parametrize("A", a=1, b=3), **Parametrize("A", a=2, c=4), ), "Failed to parametrize `a:a`:\n Parametrization group name is not unique: 'A'", diff --git a/src/python/pants/engine/internals/parser.py b/src/python/pants/engine/internals/parser.py index 1414aeb15c4..cba242fd533 100644 --- a/src/python/pants/engine/internals/parser.py +++ b/src/python/pants/engine/internals/parser.py @@ -105,7 +105,7 @@ def __post_init__(self, type_hints: Any) -> None: if typing.get_origin(type_hints) is Annotated: annotated_type, *metadata = typing.get_args(type_hints) for meta in metadata: - if isinstance(meta, typing_extensions.Doc): # type: ignore[attr-defined] + if isinstance(meta, typing_extensions.Doc): help = meta.documentation break else: diff --git a/src/python/pants/engine/internals/selectors_test.py b/src/python/pants/engine/internals/selectors_test.py index 78e92739ca2..d8dae2bdedd 100644 --- a/src/python/pants/engine/internals/selectors_test.py +++ b/src/python/pants/engine/internals/selectors_test.py @@ -53,7 +53,7 @@ def assert_invalid_get(create_get: Callable[[], Get], *, expected: str) -> None: def test_invalid_get() -> None: # Bad output type. assert_invalid_get( - lambda: Get(1, str, "bob"), # type: ignore[call-overload, no-any-return] + lambda: Get(1, str, "bob"), # type: ignore[call-overload] expected=( "Invalid Get. The first argument (the output type) must be a type, but given " f"`1` with type {int}." diff --git a/src/python/pants/engine/target.py b/src/python/pants/engine/target.py index 1324116fb71..05657f73859 100644 --- a/src/python/pants/engine/target.py +++ b/src/python/pants/engine/target.py @@ -1849,7 +1849,7 @@ def validate(self, num: float | int | None, alias: str, address: Address) -> Non if num is None or self == self.all: # type: ignore[comparison-overlap] return if self == self.positive_and_zero: # type: ignore[comparison-overlap] - if num < 0: + if num < 0: # type: ignore[unreachable] raise InvalidFieldException( f"The {repr(alias)} field in target {address} must be greater than or equal to " f"zero, but was set to `{num}`." diff --git a/src/python/pants/engine/unions_test.py b/src/python/pants/engine/unions_test.py index b72b0994ab7..45a707b394b 100644 --- a/src/python/pants/engine/unions_test.py +++ b/src/python/pants/engine/unions_test.py @@ -79,9 +79,9 @@ class Rigatoni(Pasta): assert dataclasses.is_dataclass(Pasta.Shape) assert dataclasses.is_dataclass(Spaghetti.Shape) assert dataclasses.is_dataclass(Rigatoni.Shape) - assert Pasta.Shape(True).round - assert Spaghetti.Shape(True).round - assert Rigatoni.Shape(True).round + assert Pasta.Shape(True).round # type: ignore[call-arg, attr-defined] + assert Spaghetti.Shape(True).round # type: ignore[call-arg, attr-defined] + assert Rigatoni.Shape(True).round # type: ignore[call-arg, attr-defined] # Also on class instances, just spot-checking assert Pasta().Shape is Pasta.Shape diff --git a/src/python/pants/option/custom_types.py b/src/python/pants/option/custom_types.py index 3d92b692be3..c3769841d20 100644 --- a/src/python/pants/option/custom_types.py +++ b/src/python/pants/option/custom_types.py @@ -149,7 +149,7 @@ def memory_size(s: str | int | float) -> int: def convert_to_bytes(power_of_2) -> int: try: - return int(float(s[:-3]) * (2**power_of_2)) # type: ignore[index] + return int(float(s[:-3]) * (2**power_of_2)) except TypeError: raise invalid diff --git a/src/python/pants/option/global_options.py b/src/python/pants/option/global_options.py index 8d8c12b6876..6ae7843a9f2 100644 --- a/src/python/pants/option/global_options.py +++ b/src/python/pants/option/global_options.py @@ -800,7 +800,7 @@ class LogLevelOption(EnumOption[LogLevel, LogLevel]): def __new__(cls) -> LogLevelOption: self = super().__new__( - cls, # type: ignore[arg-type] + cls, default=LogLevel.INFO, daemon=True, help="Set the logging level.", diff --git a/src/python/pants/option/option_types.py b/src/python/pants/option/option_types.py index 8e3413c88de..253196361c7 100644 --- a/src/python/pants/option/option_types.py +++ b/src/python/pants/option/option_types.py @@ -247,7 +247,7 @@ def __new__( ): default = default or [] instance = super().__new__( - cls, # type: ignore[arg-type] + cls, flag_name, default=default, # type: ignore[arg-type] help=help, @@ -765,9 +765,9 @@ def __new__( fingerprint: bool | None = None, ): return super().__new__( - cls, # type: ignore[arg-type] + cls, flag_name, - default=default, # type: ignore[arg-type] + default=default, help=help, register_if=register_if, advanced=advanced, @@ -798,8 +798,8 @@ def __new__(cls, goal: str, *other_goals: str): goals = (goal,) + other_goals invocation_str = " and ".join([f"`{bin_name()} {goal}`" for goal in goals]) return super().__new__( - cls, # type: ignore[arg-type] - default=False, # type: ignore[arg-type] + cls, + default=False, help=lambda subsystem_cls: ( f"If true, don't use {subsystem_cls.name} when running {invocation_str}." ), @@ -823,7 +823,7 @@ def __new__( if extra_help: extra_help = "\n\n" + extra_help instance = super().__new__( - cls, # type: ignore[arg-type] + cls, help=( lambda subsystem_cls: softwrap( f""" diff --git a/src/python/pants/util/memo.py b/src/python/pants/util/memo.py index bff102b9422..9054e4ef9ba 100644 --- a/src/python/pants/util/memo.py +++ b/src/python/pants/util/memo.py @@ -249,7 +249,7 @@ def memoized_property( getter = memoized_method(func=func, key_factory=key_factory, cache_factory=cache_factory) return property( # type: ignore[return-value] fget=getter, - fdel=lambda self: getter.forget(self), # type: ignore[attr-defined, no-any-return] + fdel=lambda self: getter.forget(self), # type: ignore[attr-defined] ) @@ -283,5 +283,5 @@ def setter(self, val): return property( # type: ignore[return-value] fget=getter, fset=setter, - fdel=lambda self: getter.forget(self), # type: ignore[attr-defined, no-any-return] + fdel=lambda self: getter.forget(self), # type: ignore[attr-defined] ) diff --git a/src/python/pants/util/meta.py b/src/python/pants/util/meta.py index f6b6731cec9..e50429a190f 100644 --- a/src/python/pants/util/meta.py +++ b/src/python/pants/util/meta.py @@ -43,7 +43,7 @@ def __get__(self, obj: T, objtype: Optional[Type[T]] = None) -> Any: # Get the callable field for this object, which may be a property. callable_field = self.fget.__get__(obj, objtype) if getattr(self.fget.__func__, "__isabstractmethod__", False): - field_name = self.fget.__func__.fget.__name__ # type: ignore[attr-defined] + field_name = self.fget.__func__.fget.__name__ # type: ignore[union-attr] raise TypeError( """\ The classproperty '{func_name}' in type '{type_name}' was an abstractproperty, meaning that type \ diff --git a/src/python/pants/util/pip_requirement.py b/src/python/pants/util/pip_requirement.py index f2ed67e6ebc..0fdd297d98c 100644 --- a/src/python/pants/util/pip_requirement.py +++ b/src/python/pants/util/pip_requirement.py @@ -1,13 +1,17 @@ # Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). +# mypy: disable-error-code="import-untyped" +# Disables checking of the `pkg_resources` below which was awkward to figure out how to disable +# with a `# type: ignore[import-untyped]` comment. + from __future__ import annotations import logging import urllib.parse import pkg_resources -from pkg_resources.extern.packaging.requirements import InvalidRequirement # type: ignore[import] +from pkg_resources.extern.packaging.requirements import InvalidRequirement logger = logging.getLogger(__name__) diff --git a/src/python/pants/util/strutil.py b/src/python/pants/util/strutil.py index 776e0d532a5..245dafe292d 100644 --- a/src/python/pants/util/strutil.py +++ b/src/python/pants/util/strutil.py @@ -329,7 +329,7 @@ def help_text(val: str | Callable[[], str]) -> str | Callable[[], str]: if isinstance(val, str): return softwrap(val) else: - return lambda: softwrap(val()) # type: ignore[operator] + return lambda: softwrap(val()) P = ParamSpec("P")