Skip to content

Commit be5e9ec

Browse files
authored
chore(ruff): Fix UP006 warnings during codegen (#3746)
1 parent b6253ff commit be5e9ec

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tools/generate_schema_wrapper.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ def generate_vegalite_schema_wrapper(fp: Path, /) -> ModuleDef[str]:
753753
all_ = [*sorted(it), "Root", "VegaLiteSchema", "SchemaBase", "load_schema"]
754754
contents = [
755755
HEADER,
756-
"from typing import Any, Literal, Union, Protocol, Sequence, List, Iterator, TYPE_CHECKING",
756+
"from collections.abc import Iterator, Sequence",
757+
"from typing import Any, Literal, Union, Protocol, TYPE_CHECKING",
757758
"import pkgutil",
758759
"import json\n",
759760
"import narwhals.stable.v1 as nw\n",
@@ -871,7 +872,8 @@ def generate_vegalite_channel_wrappers(fp: Path, /) -> ModuleDef[list[str]]:
871872
all_ = sorted(chain(it, COMPAT_EXPORTS))
872873
imports = [
873874
"import sys",
874-
"from typing import Any, overload, Sequence, List, Literal, Union, TYPE_CHECKING, TypedDict",
875+
"from collections.abc import Sequence",
876+
"from typing import Any, overload, Literal, Union, TYPE_CHECKING, TypedDict",
875877
import_typing_extensions((3, 10), "TypeAlias"),
876878
"import narwhals.stable.v1 as nw",
877879
"from altair.utils.schemapi import Undefined, with_property_setters",
@@ -1226,7 +1228,8 @@ def vegalite_main(skip_download: bool = False) -> None:
12261228
fp_mixins = schemapath / "mixins.py"
12271229
print(f"Generating\n {schemafile!s}\n ->{fp_mixins!s}")
12281230
mixins_imports = (
1229-
"from typing import Any, Sequence, List, Literal, Union",
1231+
"from collections.abc import Sequence",
1232+
"from typing import Any, Literal, Union",
12301233
"from altair.utils import use_signature, Undefined, SchemaBase",
12311234
"from . import core",
12321235
)
@@ -1256,7 +1259,8 @@ def vegalite_main(skip_download: bool = False) -> None:
12561259
fp_theme_config: Path = schemapath / "_config.py"
12571260
content_theme_config = [
12581261
HEADER,
1259-
"from typing import Any, TYPE_CHECKING, Literal, Sequence, TypedDict, Union",
1262+
"from collections.abc import Sequence",
1263+
"from typing import Any, TYPE_CHECKING, Literal, TypedDict, Union",
12601264
import_typing_extensions((3, 14), "TypedDict", include_sys=True),
12611265
f"from ._typing import {ROW_COL_KWDS}, {PADDING_KWDS}",
12621266
"\n\n",

tools/schemapi/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def __init__(self, fmt: str = "{}_T") -> None:
124124
"from __future__ import annotations\n",
125125
"import sys",
126126
"from datetime import date, datetime",
127-
"from typing import Annotated, Any, Generic, Literal, Mapping, TypeVar, Sequence, Union, get_args",
127+
"from collections.abc import Sequence, Mapping",
128+
"from typing import Annotated, Any, Generic, Literal, TypeVar, Union, get_args",
128129
"import re",
129130
import_typing_extensions(
130131
(3, 14), "TypedDict", reason="https://peps.python.org/pep-0728/"

0 commit comments

Comments
 (0)