Skip to content

Commit 683e852

Browse files
author
Caio Fontes
committed
chore: fix linting
1 parent 631a65c commit 683e852

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

elasticsearch_dsl/function.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@
1717

1818
import collections.abc
1919
from copy import deepcopy
20-
from typing import Dict, Optional, ClassVar, Union, MutableMapping, Any
20+
from typing import Any, ClassVar, Dict, MutableMapping, Optional, Union, overload
2121

2222
from .utils import DslBase, _JSONSafeTypes
2323

2424

25-
def SF(name_or_sf: Union[str, "ScoreFunction", MutableMapping[str, Any]], **params: Any) -> "ScoreFunction":
25+
@overload
26+
def SF(name_or_sf: MutableMapping[str, Any]) -> "ScoreFunction": ...
27+
28+
29+
@overload
30+
def SF(name_or_sf: "ScoreFunction") -> "ScoreFunction": ...
31+
32+
33+
@overload
34+
def SF(name_or_sf: str, **params: Any) -> "ScoreFunction": ...
35+
36+
37+
def SF(
38+
name_or_sf: Union[str, "ScoreFunction", MutableMapping[str, Any]],
39+
**params: Any,
40+
) -> "ScoreFunction":
2641
# {"script_score": {"script": "_score"}, "filter": {}}
2742
if isinstance(name_or_sf, collections.abc.MutableMapping):
2843
if params:

elasticsearch_dsl/utils.py

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

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

2323
from typing_extensions import Self
2424

2525
from .exceptions import UnknownDslObject, ValidationException
2626

27-
_JSONSafeTypes = Union[int, bool, str, float, List["_JSONSafeTypes"], Dict[str, "_JSONSafeTypes"]]
27+
_JSONSafeTypes = Union[
28+
int, bool, str, float, List["_JSONSafeTypes"], Dict[str, "_JSONSafeTypes"]
29+
]
2830

2931
SKIP_VALUES = ("", None)
3032
EXPAND__TO_DOT = True
@@ -212,7 +214,7 @@ class DslMeta(type):
212214
For typical use see `QueryMeta` and `Query` in `elasticsearch_dsl.query`.
213215
"""
214216

215-
_types: ClassVar[Dict[str, type["DslBase"]]] = {}
217+
_types: ClassVar[Dict[str, Type["DslBase"]]] = {}
216218

217219
def __init__(cls, name, bases, attrs):
218220
super().__init__(name, bases, attrs)

0 commit comments

Comments
 (0)