Skip to content

Commit

Permalink
type ignores for pipe syntax in 3.8/3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Nov 5, 2024
1 parent 0732365 commit 85b67ed
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion elasticsearch_dsl/document_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)

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

Expand Down
2 changes: 1 addition & 1 deletion elasticsearch_dsl/response/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


class Response(AttrDict[Any], Generic[_R]):
"""An Elasticsearch response.
"""An Elasticsearch _search response.
:arg took: (required)
:arg timed_out: (required)
Expand Down
8 changes: 4 additions & 4 deletions tests/_async/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,13 @@ def test_doc_with_pipe_type_hints() -> None:

class BadlyTypedDoc(AsyncDocument):
s: str
f: str | int | None
f: str | int | None # type: ignore[syntax]

class TypedDoc(AsyncDocument):
s: str
f1: str | None
f2: M[int | None]
f3: M[datetime | None]
f1: str | None # type: ignore[syntax]
f2: M[int | None] # type: ignore[syntax]
f3: M[datetime | None] # type: ignore[syntax]

props = TypedDoc._doc_type.mapping.to_dict()["properties"]
assert props == {
Expand Down
8 changes: 4 additions & 4 deletions tests/_sync/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,13 @@ def test_doc_with_pipe_type_hints() -> None:

class BadlyTypedDoc(Document):
s: str
f: str | int | None
f: str | int | None # type: ignore[syntax]

class TypedDoc(Document):
s: str
f1: str | None
f2: M[int | None]
f3: M[datetime | None]
f1: str | None # type: ignore[syntax]
f2: M[int | None] # type: ignore[syntax]
f3: M[datetime | None] # type: ignore[syntax]

props = TypedDoc._doc_type.mapping.to_dict()["properties"]
assert props == {
Expand Down
2 changes: 1 addition & 1 deletion utils/templates/response.__init__.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ __all__ = ["Response", "AggResponse", "UpdateByQueryResponse", "Hit", "HitMeta"]


class Response(AttrDict[Any], Generic[_R]):
"""An Elasticsearch _search response.
"""An Elasticsearch search response.

{% for arg in response.args %}
{% for line in arg.doc %}
Expand Down

0 comments on commit 85b67ed

Please sign in to comment.