Remove redundant mock backport dependency and upgrade syntax for Python 3.8+ (#785)

* Upgrade syntax with pyupgrade --py38-plus

Signed-off-by: Hugo van Kemenade <[email protected]>

* Convert to f-strings with flynt

Signed-off-by: Hugo van Kemenade <[email protected]>

* Format with Black

Signed-off-by: Hugo van Kemenade <[email protected]>

* Remove redundant mock backport dependency

Signed-off-by: Hugo van Kemenade <[email protected]>

* isort imports

Signed-off-by: Hugo van Kemenade <[email protected]>

* Add changelog entry

Signed-off-by: Hugo van Kemenade <[email protected]>

---------

Signed-off-by: Hugo van Kemenade <[email protected]>
This commit is contained in:
Hugo van Kemenade
2024-07-20 16:19:20 -04:00
committed by GitHub
parent de96d28e45
commit 6e3f1a1194
95 changed files with 229 additions and 300 deletions
+3 -3
View File
@@ -48,7 +48,7 @@ def SF(name_or_sf: Any, **params: Any) -> Any: # pylint: disable=invalid-name
elif len(sf) == 1:
name, params = sf.popitem()
else:
raise ValueError("SF() got an unexpected fields in the dictionary: %r" % sf)
raise ValueError(f"SF() got an unexpected fields in the dictionary: {sf!r}")
# boost factor special case, see https://github.com/elastic/elasticsearch/issues/6343
if not isinstance(params, collections_abc.Mapping):
@@ -81,7 +81,7 @@ class ScoreFunction(DslBase):
name: Optional[str] = None
def to_dict(self) -> Any:
d = super(ScoreFunction, self).to_dict()
d = super().to_dict()
# filter and query dicts should be at the same level as us
for k in self._param_defs:
if k in d[self.name]:
@@ -97,7 +97,7 @@ class BoostFactor(ScoreFunction):
name = "boost_factor"
def to_dict(self) -> Any:
d = super(BoostFactor, self).to_dict()
d = super().to_dict()
if "value" in d[self.name]:
d[self.name] = d[self.name].pop("value")
else: