Skip to content

Commit 1a8e62c

Browse files
committed
feat: add first type annotations
1 parent be934a4 commit 1a8e62c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

elasticsearch_dsl/function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818
import collections.abc
19-
from typing import Dict
19+
from typing import Dict, Optional, ClassVar
2020

2121
from .utils import DslBase
2222

@@ -70,7 +70,7 @@ class ScoreFunction(DslBase):
7070
"filter": {"type": "query"},
7171
"weight": {},
7272
}
73-
name = None
73+
name: ClassVar[Optional[str]] = None
7474

7575
def to_dict(self):
7676
d = super().to_dict()

elasticsearch_dsl/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import collections.abc
2020
from copy import copy
21-
from typing import Any, Dict, Optional, Type
21+
from typing import Any, Dict, Optional, Type, ClassVar, Union
2222

2323
from typing_extensions import Self
2424

@@ -210,7 +210,7 @@ class DslMeta(type):
210210
For typical use see `QueryMeta` and `Query` in `elasticsearch_dsl.query`.
211211
"""
212212

213-
_types = {}
213+
_types: ClassVar[Dict[str, type["DslBase"]]] = {}
214214

215215
def __init__(cls, name, bases, attrs):
216216
super().__init__(name, bases, attrs)
@@ -251,7 +251,7 @@ class DslBase(metaclass=DslMeta):
251251
all values in the `must` attribute into Query objects)
252252
"""
253253

254-
_param_defs = {}
254+
_param_defs: ClassVar[Dict[str, Dict[str, Union[str, bool]]]] = {}
255255

256256
@classmethod
257257
def get_dsl_class(

noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131

3232
TYPED_FILES = (
33+
"elasticsearch_dsl/function.py",
3334
"elasticsearch_dsl/query.py",
3435
"tests/test_query.py",
3536
)

0 commit comments

Comments
 (0)