Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jan 13, 2025
1 parent 7b1af33 commit 2bde52a
Show file tree
Hide file tree
Showing 47 changed files with 75 additions and 57 deletions.
3 changes: 2 additions & 1 deletion elasticsearch/dsl/_async/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
cast,
)

from typing_extensions import Self, dataclass_transform

from elasticsearch.exceptions import NotFoundError, RequestError
from elasticsearch.helpers import async_bulk
from typing_extensions import Self, dataclass_transform

from .._async.index import AsyncIndex
from ..async_connections import get_connection
Expand Down
1 change: 0 additions & 1 deletion elasticsearch/dsl/_async/faceted_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from typing import TYPE_CHECKING

from ..faceted_search_base import FacetedResponse, FacetedSearchBase

from ..utils import _R
from .search import AsyncSearch

Expand Down
1 change: 1 addition & 0 deletions elasticsearch/dsl/_async/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

if TYPE_CHECKING:
from elastic_transport import ObjectApiResponse

from elasticsearch import AsyncElasticsearch


Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/dsl/_async/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
cast,
)

from typing_extensions import Self

from elasticsearch.exceptions import ApiError
from elasticsearch.helpers import async_scan
from typing_extensions import Self

from ..async_connections import get_connection
from ..response import Response
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/dsl/_sync/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
cast,
)

from typing_extensions import Self, dataclass_transform

from elasticsearch.exceptions import NotFoundError, RequestError
from elasticsearch.helpers import bulk
from typing_extensions import Self, dataclass_transform

from .._sync.index import Index
from ..connections import get_connection
Expand Down
1 change: 0 additions & 1 deletion elasticsearch/dsl/_sync/faceted_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from typing import TYPE_CHECKING

from ..faceted_search_base import FacetedResponse, FacetedSearchBase

from ..utils import _R
from .search import Search

Expand Down
1 change: 1 addition & 0 deletions elasticsearch/dsl/_sync/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

if TYPE_CHECKING:
from elastic_transport import ObjectApiResponse

from elasticsearch import Elasticsearch


Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/dsl/_sync/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import contextlib
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, cast

from typing_extensions import Self

from elasticsearch.exceptions import ApiError
from elasticsearch.helpers import scan
from typing_extensions import Self

from ..connections import get_connection
from ..response import Response
Expand Down
1 change: 0 additions & 1 deletion elasticsearch/dsl/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from elastic_transport.client_utils import DefaultType

from . import types

from .document_base import InstrumentedField
from .search_base import SearchBase

Expand Down
4 changes: 2 additions & 2 deletions elasticsearch/dsl/document_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
)

try:
from types import UnionType # type: ignore[attr-defined]
from types import UnionType
except ImportError:
UnionType = None
UnionType = None # type: ignore

from typing_extensions import dataclass_transform

Expand Down
1 change: 0 additions & 1 deletion elasticsearch/dsl/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
from elastic_transport.client_utils import DefaultType

from . import types, wrappers

from .document_base import InstrumentedField

_T = TypeVar("_T")
Expand Down
12 changes: 2 additions & 10 deletions elasticsearch/dsl/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
# specific language governing permissions and limitations
# under the License.

from ._async.search import ( # noqa: F401
AsyncEmptySearch,
AsyncMultiSearch,
AsyncSearch,
)
from ._sync.search import ( # noqa: F401
EmptySearch,
MultiSearch,
Search,
)
from ._async.search import AsyncEmptySearch, AsyncMultiSearch, AsyncSearch # noqa: F401
from ._sync.search import EmptySearch, MultiSearch, Search # noqa: F401
from .search_base import Q # noqa: F401
1 change: 1 addition & 0 deletions elasticsearch/dsl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

if TYPE_CHECKING:
from elastic_transport import ObjectApiResponse

from elasticsearch import AsyncElasticsearch, Elasticsearch

from .document_base import DocumentOptions
Expand Down
3 changes: 1 addition & 2 deletions examples/dsl/async/composite_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import os
from typing import Any, AsyncIterator, Dict, Mapping, Sequence, cast

from elasticsearch.helpers import async_bulk

from elasticsearch.dsl import Agg, AsyncSearch, Response, aggs, async_connections
from elasticsearch.dsl.types import CompositeAggregate
from elasticsearch.helpers import async_bulk
from test_elasticsearch.test_dsl.test_integration.test_data import DATA, GIT_INDEX


Expand Down
3 changes: 1 addition & 2 deletions examples/dsl/composite_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import os
from typing import Any, Dict, Iterator, Mapping, Sequence, cast

from elasticsearch.helpers import bulk

from elasticsearch.dsl import Agg, Response, Search, aggs, connections
from elasticsearch.dsl.types import CompositeAggregate
from elasticsearch.helpers import bulk
from test_elasticsearch.test_dsl.test_integration.test_data import DATA, GIT_INDEX


Expand Down
26 changes: 23 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ def lint(session):
session.run("python", "-c", "from elasticsearch._otel import OpenTelemetry")

session.install(
"flake8", "black~=24.0", "mypy", "isort", "types-requests", "unasync>=0.6.0"
"flake8",
"black~=24.0",
"mypy",
"isort",
"types-requests",
"types-python-dateutil",
"unasync>=0.6.0",
)
session.run("isort", "--check", "--profile=black", *SOURCE_FILES)
session.run("black", "--check", *SOURCE_FILES)
Expand All @@ -98,7 +104,14 @@ def lint(session):

# 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",
"--implicit-reexport",
"--explicit-package-bases",
"--show-error-codes",
"elasticsearch/",
)
session.run(
"mypy",
"--strict",
Expand All @@ -115,7 +128,14 @@ def lint(session):
# 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/",
)
session.run(
"mypy",
"--strict",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[flake8]
ignore = E203, E266, E501, W503
ignore = E203, E266, E501, W503, E704, E741
6 changes: 3 additions & 3 deletions test_elasticsearch/test_dsl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

import pytest_asyncio
from elastic_transport import ObjectApiResponse
from elasticsearch import AsyncElasticsearch, Elasticsearch
from elasticsearch.exceptions import ConnectionError
from elasticsearch.helpers import bulk
from pytest import fixture, skip

from elasticsearch import AsyncElasticsearch, Elasticsearch
from elasticsearch.dsl import Search
from elasticsearch.dsl.async_connections import add_connection as add_async_connection
from elasticsearch.dsl.async_connections import connections as async_connections
from elasticsearch.dsl.connections import add_connection, connections
from elasticsearch.exceptions import ConnectionError
from elasticsearch.helpers import bulk

from .test_integration._async import test_document as async_document
from .test_integration._sync import test_document as sync_document
Expand Down
2 changes: 1 addition & 1 deletion test_elasticsearch/test_dsl/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

from typing import Any, List

from elasticsearch import Elasticsearch
from pytest import raises

from elasticsearch import Elasticsearch
from elasticsearch.dsl import connections, serializer


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

import pytest
from elasticsearch import AsyncElasticsearch

from elasticsearch import AsyncElasticsearch
from elasticsearch.dsl import analyzer, token_filter, tokenizer


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Tuple, Union

import pytest
from elasticsearch import AsyncElasticsearch, ConflictError, NotFoundError
from elasticsearch.helpers.errors import BulkIndexError
from pytest import raises
from pytz import timezone

from elasticsearch import AsyncElasticsearch, ConflictError, NotFoundError
from elasticsearch.dsl import (
AsyncDocument,
AsyncSearch,
Expand All @@ -54,6 +53,7 @@
mapped_field,
)
from elasticsearch.dsl.utils import AttrList
from elasticsearch.helpers.errors import BulkIndexError

snowball = analyzer("my_snow", tokenizer="standard", filter=["lowercase", "snowball"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from typing import Tuple, Type

import pytest
from elasticsearch import AsyncElasticsearch

from elasticsearch import AsyncElasticsearch
from elasticsearch.dsl import A, AsyncDocument, AsyncSearch, Boolean, Date, Keyword
from elasticsearch.dsl.faceted_search import (
AsyncFacetedSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

import pytest
from elasticsearch import AsyncElasticsearch

from elasticsearch import AsyncElasticsearch
from elasticsearch.dsl import (
AsyncComposableIndexTemplate,
AsyncDocument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# under the License.

import pytest
from elasticsearch import AsyncElasticsearch
from pytest import raises

from elasticsearch import AsyncElasticsearch
from elasticsearch.dsl import AsyncMapping, analysis, exceptions


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


import pytest
from elasticsearch import ApiError, AsyncElasticsearch
from pytest import raises

from elasticsearch import ApiError, AsyncElasticsearch
from elasticsearch.dsl import (
AsyncDocument,
AsyncMultiSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

import pytest
from elasticsearch import AsyncElasticsearch

from elasticsearch import AsyncElasticsearch
from elasticsearch.dsl import AsyncUpdateByQuery
from elasticsearch.dsl.search import Q

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

import pytest
from elasticsearch import Elasticsearch

from elasticsearch import Elasticsearch
from elasticsearch.dsl import analyzer, token_filter, tokenizer


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Tuple, Union

import pytest
from elasticsearch import ConflictError, Elasticsearch, NotFoundError
from elasticsearch.helpers.errors import BulkIndexError
from pytest import raises
from pytz import timezone

from elasticsearch import ConflictError, Elasticsearch, NotFoundError
from elasticsearch.dsl import (
Binary,
Boolean,
Expand All @@ -54,6 +53,7 @@
mapped_field,
)
from elasticsearch.dsl.utils import AttrList
from elasticsearch.helpers.errors import BulkIndexError

snowball = analyzer("my_snow", tokenizer="standard", filter=["lowercase", "snowball"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from typing import Tuple, Type

import pytest
from elasticsearch import Elasticsearch

from elasticsearch import Elasticsearch
from elasticsearch.dsl import A, Boolean, Date, Document, Keyword, Search
from elasticsearch.dsl.faceted_search import (
DateHistogramFacet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

import pytest
from elasticsearch import Elasticsearch

from elasticsearch import Elasticsearch
from elasticsearch.dsl import (
ComposableIndexTemplate,
Date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# under the License.

import pytest
from elasticsearch import Elasticsearch
from pytest import raises

from elasticsearch import Elasticsearch
from elasticsearch.dsl import Mapping, analysis, exceptions


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


import pytest
from elasticsearch import ApiError, Elasticsearch
from pytest import raises

from elasticsearch import ApiError, Elasticsearch
from elasticsearch.dsl import Date, Document, Keyword, MultiSearch, Q, Search, Text
from elasticsearch.dsl.response import aggs

Expand Down
Loading

0 comments on commit 2bde52a

Please sign in to comment.