diff --git a/elasticsearch/__init__.py b/elasticsearch/__init__.py index 723b3a2b7..c2277228a 100644 --- a/elasticsearch/__init__.py +++ b/elasticsearch/__init__.py @@ -27,7 +27,7 @@ from ._version import __versionstr__ # Ensure that a compatible version of elastic-transport is installed. -_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore +_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore[union-attr] if _version_groups < (8, 0, 0) or _version_groups > (9, 0, 0): raise ImportError( "An incompatible version of elastic-transport is installed. Must be between " @@ -35,7 +35,7 @@ "$ python -m pip install 'elastic-transport>=8, <9'" ) -_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore +_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore[assignment, union-attr] _major, _minor, _patch = (int(x) for x in _version_groups) VERSION = __version__ = (_major, _minor, _patch) diff --git a/elasticsearch/_async/helpers.py b/elasticsearch/_async/helpers.py index 1bc339917..4c53f0bbe 100644 --- a/elasticsearch/_async/helpers.py +++ b/elasticsearch/_async/helpers.py @@ -257,7 +257,7 @@ async def map_actions() -> AsyncIterable[_TYPE_BULK_ACTION_HEADER_AND_BODY]: ] ok: bool info: Dict[str, Any] - async for data, (ok, info) in azip( # type: ignore + async for data, (ok, info) in azip( # type: ignore[assignment, misc] bulk_data, _process_bulk_chunk( client, diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index c5ec21dae..9f957987c 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -232,7 +232,7 @@ def host_mapping_to_node_config(host: Mapping[str, Union[str, int]]) -> NodeConf ) options["path_prefix"] = options.pop("url_prefix") - return NodeConfig(**options) # type: ignore + return NodeConfig(**options) # type: ignore[arg-type] def cloud_id_to_node_configs(cloud_id: str) -> List[NodeConfig]: diff --git a/elasticsearch/helpers/actions.py b/elasticsearch/helpers/actions.py index 687bf4b84..d1a43a8dc 100644 --- a/elasticsearch/helpers/actions.py +++ b/elasticsearch/helpers/actions.py @@ -593,7 +593,7 @@ def parallel_bulk( class BlockingPool(ThreadPool): def _setup_queues(self) -> None: - super()._setup_queues() # type: ignore + super()._setup_queues() # type: ignore[misc] # The queue must be at least the size of the number of threads to # prevent hanging when inserting sentinel values during teardown. self._inqueue: Queue[ diff --git a/noxfile.py b/noxfile.py index bd1dbce3b..f07edbd8d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -75,8 +75,6 @@ def format(session): session.run("black", *SOURCE_FILES) session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES) - lint(session) - @nox.session() def lint(session): @@ -96,30 +94,28 @@ def lint(session): session.install(".[async,requests,orjson,pyarrow,vectorstore_mmr]", env=INSTALL_ENV) - # Run mypy on the package and then the type examples separately for - # the two different mypy use-cases, ourselves and our users. - session.run("mypy", "--strict", "--show-error-codes", "elasticsearch/") - session.run( - "mypy", - "--strict", - "--show-error-codes", - "test_elasticsearch/test_types/sync_types.py", - ) + # Run mypy on the package, the type examples and the DSL examples session.run( "mypy", "--strict", + "--implicit-reexport", + "--explicit-package-bases", "--show-error-codes", - "test_elasticsearch/test_types/async_types.py", + "--enable-error-code=ignore-without-code", + "elasticsearch/", + "test_elasticsearch/test_types/", ) # Make sure we don't require aiohttp to be installed for users to # receive type hint information from mypy. session.run("python", "-m", "pip", "uninstall", "--yes", "aiohttp") - session.run("mypy", "--strict", "--show-error-codes", "elasticsearch/") session.run( "mypy", "--strict", + "--implicit-reexport", + "--explicit-package-bases", "--show-error-codes", + "elasticsearch/", "test_elasticsearch/test_types/sync_types.py", )