Skip to content

[8.17] Simplify lint and format nox sessions (#2790) #2793

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

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions elasticsearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
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 "
"v8.0.0 and v9.0.0. Install the correct version with the following command: "
"$ 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)

Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_async/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_sync/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/helpers/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down
22 changes: 9 additions & 13 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
)

Expand Down