Skip to content

Commit 894a4be

Browse files
authored
[8.17] Simplify lint and format nox sessions (#2790) (#2793)
* Simplify lint and format nox sessions (#2790) (cherry picked from commit 4d5060b) # Conflicts: # noxfile.py * Add missing error codes
1 parent bc822d4 commit 894a4be

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

elasticsearch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
from ._version import __versionstr__
2828

2929
# Ensure that a compatible version of elastic-transport is installed.
30-
_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore
30+
_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore[union-attr]
3131
if _version_groups < (8, 0, 0) or _version_groups > (9, 0, 0):
3232
raise ImportError(
3333
"An incompatible version of elastic-transport is installed. Must be between "
3434
"v8.0.0 and v9.0.0. Install the correct version with the following command: "
3535
"$ python -m pip install 'elastic-transport>=8, <9'"
3636
)
3737

38-
_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore
38+
_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore[assignment, union-attr]
3939
_major, _minor, _patch = (int(x) for x in _version_groups)
4040
VERSION = __version__ = (_major, _minor, _patch)
4141

elasticsearch/_async/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async def map_actions() -> AsyncIterable[_TYPE_BULK_ACTION_HEADER_AND_BODY]:
257257
]
258258
ok: bool
259259
info: Dict[str, Any]
260-
async for data, (ok, info) in azip( # type: ignore
260+
async for data, (ok, info) in azip( # type: ignore[assignment, misc]
261261
bulk_data,
262262
_process_bulk_chunk(
263263
client,

elasticsearch/_sync/client/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def host_mapping_to_node_config(host: Mapping[str, Union[str, int]]) -> NodeConf
232232
)
233233
options["path_prefix"] = options.pop("url_prefix")
234234

235-
return NodeConfig(**options) # type: ignore
235+
return NodeConfig(**options) # type: ignore[arg-type]
236236

237237

238238
def cloud_id_to_node_configs(cloud_id: str) -> List[NodeConfig]:

elasticsearch/helpers/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def parallel_bulk(
593593

594594
class BlockingPool(ThreadPool):
595595
def _setup_queues(self) -> None:
596-
super()._setup_queues() # type: ignore
596+
super()._setup_queues() # type: ignore[misc]
597597
# The queue must be at least the size of the number of threads to
598598
# prevent hanging when inserting sentinel values during teardown.
599599
self._inqueue: Queue[

noxfile.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def format(session):
7575
session.run("black", *SOURCE_FILES)
7676
session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES)
7777

78-
lint(session)
79-
8078

8179
@nox.session()
8280
def lint(session):
@@ -96,30 +94,28 @@ def lint(session):
9694

9795
session.install(".[async,requests,orjson,pyarrow,vectorstore_mmr]", env=INSTALL_ENV)
9896

99-
# Run mypy on the package and then the type examples separately for
100-
# the two different mypy use-cases, ourselves and our users.
101-
session.run("mypy", "--strict", "--show-error-codes", "elasticsearch/")
102-
session.run(
103-
"mypy",
104-
"--strict",
105-
"--show-error-codes",
106-
"test_elasticsearch/test_types/sync_types.py",
107-
)
97+
# Run mypy on the package, the type examples and the DSL examples
10898
session.run(
10999
"mypy",
110100
"--strict",
101+
"--implicit-reexport",
102+
"--explicit-package-bases",
111103
"--show-error-codes",
112-
"test_elasticsearch/test_types/async_types.py",
104+
"--enable-error-code=ignore-without-code",
105+
"elasticsearch/",
106+
"test_elasticsearch/test_types/",
113107
)
114108

115109
# Make sure we don't require aiohttp to be installed for users to
116110
# receive type hint information from mypy.
117111
session.run("python", "-m", "pip", "uninstall", "--yes", "aiohttp")
118-
session.run("mypy", "--strict", "--show-error-codes", "elasticsearch/")
119112
session.run(
120113
"mypy",
121114
"--strict",
115+
"--implicit-reexport",
116+
"--explicit-package-bases",
122117
"--show-error-codes",
118+
"elasticsearch/",
123119
"test_elasticsearch/test_types/sync_types.py",
124120
)
125121

0 commit comments

Comments
 (0)