Skip to content

Commit 72bd84d

Browse files
authored
refactor(typing): reduce type ignores in api.py (vega#3480)
* refactor(typing): reduce type ignores in `api.py` * feat(typing): adds `_is_undefined` guard Direct copy from another PR, but is helpful here https://github.com/dangotbanned/altair/blob/d607c70824860ef3478d7d3996d26dc516d69369/altair/vegalite/v5/api.py#L504 * fix(typing): `ignore[index]` from vega#3455 * fix(typing): `[ignore[arg-type]` from vega#3452 * refactor(typing): use `_is_undefined` in some cases * refactor: reduce code duplication in `Chart.to_dict` * fix(typing): Recover `TopLevelMixin.resolve_` return types I removed these in 6adf564 due to how complex they were getting, but both `mypy` and `pyright` seem happy with this solution * fix(typing): narrow annotated types for `_check_if_valid_subspec` Following investigation during vega#3480 (comment) * refactor: remove unused `_wrapper_classes` argument from `SchemaBase` Fixes: - vega#3480 (comment) - vega#3480 (comment) - vega#3480 (comment)
1 parent 7f514c9 commit 72bd84d

File tree

4 files changed

+158
-162
lines changed

4 files changed

+158
-162
lines changed

altair/utils/schemapi.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,10 +1087,7 @@ def _default_wrapper_classes(cls) -> Iterator[type[SchemaBase]]:
10871087

10881088
@classmethod
10891089
def from_dict(
1090-
cls: type[TSchemaBase],
1091-
dct: dict[str, Any],
1092-
validate: bool = True,
1093-
_wrapper_classes: Iterable[type[SchemaBase]] | None = None,
1090+
cls: type[TSchemaBase], dct: dict[str, Any], validate: bool = True
10941091
) -> TSchemaBase:
10951092
"""Construct class from a dictionary representation
10961093
@@ -1100,10 +1097,6 @@ def from_dict(
11001097
The dict from which to construct the class
11011098
validate : boolean
11021099
If True (default), then validate the input against the schema.
1103-
_wrapper_classes : iterable (optional)
1104-
The set of SchemaBase classes to use when constructing wrappers
1105-
of the dict inputs. If not specified, the result of
1106-
cls._default_wrapper_classes will be used.
11071100
11081101
Returns
11091102
-------
@@ -1117,9 +1110,7 @@ def from_dict(
11171110
"""
11181111
if validate:
11191112
cls.validate(dct)
1120-
if _wrapper_classes is None:
1121-
_wrapper_classes = cls._default_wrapper_classes()
1122-
converter = _FromDict(_wrapper_classes)
1113+
converter = _FromDict(cls._default_wrapper_classes())
11231114
return converter.from_dict(dct, cls)
11241115

11251116
@classmethod

0 commit comments

Comments
 (0)