Skip to content

Commit

Permalink
Merge branch 'main' into vega-versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned authored Jan 2, 2025
2 parents 041eb0d + cf73537 commit d49f0ff
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 50 deletions.
3 changes: 2 additions & 1 deletion altair/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@

if TYPE_CHECKING:
import sys
from typing import Any, Callable, Literal
from collections.abc import Callable
from typing import Any, Literal

if sys.version_info >= (3, 11):
from typing import LiteralString
Expand Down
4 changes: 2 additions & 2 deletions altair/utils/_vegafusion_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import uuid
from importlib.metadata import version as importlib_version
from typing import TYPE_CHECKING, Any, Callable, Final, TypedDict, Union, overload
from typing import TYPE_CHECKING, Any, Final, TypedDict, Union, overload
from weakref import WeakValueDictionary

from narwhals.stable.v1.dependencies import is_into_dataframe
Expand All @@ -20,7 +20,7 @@

if TYPE_CHECKING:
import sys
from collections.abc import MutableMapping
from collections.abc import Callable, MutableMapping

from narwhals.stable.v1.typing import IntoDataFrame

Expand Down
3 changes: 2 additions & 1 deletion altair/utils/compiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Callable
from collections.abc import Callable
from typing import Any

from altair.utils import PluginRegistry

Expand Down
24 changes: 11 additions & 13 deletions altair/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import sys
import traceback
import warnings
from collections.abc import Iterator, Mapping, MutableMapping
from collections.abc import Callable, Iterator, Mapping, MutableMapping
from copy import deepcopy
from itertools import groupby
from operator import itemgetter
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, cast, overload
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast, overload

import jsonschema
import narwhals.stable.v1 as nw
Expand All @@ -32,8 +32,6 @@


if TYPE_CHECKING:
import typing as t

import pandas as pd
from narwhals.stable.v1.typing import IntoExpr

Expand Down Expand Up @@ -287,7 +285,7 @@ def merge_props_geom(feat: dict[str, Any]) -> dict[str, Any]:
return props_geom


def sanitize_geo_interface(geo: t.MutableMapping[Any, Any]) -> dict[str, Any]:
def sanitize_geo_interface(geo: MutableMapping[Any, Any]) -> dict[str, Any]:
"""
Santize a geo_interface to prepare it for serialization.
Expand Down Expand Up @@ -768,21 +766,21 @@ def decorate(cb: WrapsFunc[R], /) -> WrappedMethod[T, P, R] | WrappedFunc[P, R]:

@overload
def update_nested(
original: t.MutableMapping[Any, Any],
update: t.Mapping[Any, Any],
original: MutableMapping[Any, Any],
update: Mapping[Any, Any],
copy: Literal[False] = ...,
) -> t.MutableMapping[Any, Any]: ...
) -> MutableMapping[Any, Any]: ...
@overload
def update_nested(
original: t.Mapping[Any, Any],
update: t.Mapping[Any, Any],
original: Mapping[Any, Any],
update: Mapping[Any, Any],
copy: Literal[True],
) -> t.MutableMapping[Any, Any]: ...
) -> MutableMapping[Any, Any]: ...
def update_nested(
original: Any,
update: t.Mapping[Any, Any],
update: Mapping[Any, Any],
copy: bool = False,
) -> t.MutableMapping[Any, Any]:
) -> MutableMapping[Any, Any]:
"""
Update nested dictionaries.
Expand Down
13 changes: 2 additions & 11 deletions altair/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@
import json
import random
import sys
from collections.abc import MutableMapping, Sequence
from collections.abc import Callable, MutableMapping, Sequence
from functools import partial
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Callable,
Literal,
TypedDict,
TypeVar,
Union,
overload,
)
from typing import TYPE_CHECKING, Any, Literal, TypedDict, TypeVar, Union, overload

import narwhals.stable.v1 as nw
from narwhals.stable.v1.dependencies import is_pandas_dataframe
Expand Down
3 changes: 2 additions & 1 deletion altair/utils/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pkgutil
import textwrap
import uuid
from typing import TYPE_CHECKING, Any, Callable, Union
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Union

from ._vegafusion_data import compile_with_vegafusion, using_vegafusion
from .mimebundle import spec_to_mimebundle
Expand Down
3 changes: 2 additions & 1 deletion altair/utils/execeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import ast
import sys
from typing import TYPE_CHECKING, Any, Callable, Literal, overload
from typing import TYPE_CHECKING, Any, Literal, overload

if TYPE_CHECKING:
from collections.abc import Callable
from os import PathLike

from _typeshed import ReadableBuffer
Expand Down
3 changes: 2 additions & 1 deletion altair/utils/plugin_registry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

import sys
from collections.abc import Callable
from functools import partial
from importlib.metadata import entry_points
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar, cast
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast

from altair.utils.deprecation import deprecated_warn

Expand Down
4 changes: 3 additions & 1 deletion altair/vegalite/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable, overload
from typing import TYPE_CHECKING, overload

from altair.utils.core import sanitize_pandas_dataframe
from altair.utils.data import DataTransformerRegistry as _DataTransformerRegistry
Expand All @@ -15,6 +15,8 @@
)

if TYPE_CHECKING:
from collections.abc import Callable

from altair.utils.data import DataType, ToValuesReturnType
from altair.utils.plugin_registry import PluginEnabler

Expand Down
4 changes: 2 additions & 2 deletions altair/vegalite/v5/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def _reveal_parsed_shorthand(obj: Map, /) -> dict[str, Any]:

def _is_extra(*objs: Any, kwds: Map) -> Iterator[bool]:
for el in objs:
if isinstance(el, (SchemaBase, t.Mapping)):
if isinstance(el, (SchemaBase, Mapping)):
item = el.to_dict(validate=False) if isinstance(el, SchemaBase) else el
yield not (item.keys() - kwds.keys()).isdisjoint(utils.SHORTHAND_KEYS)
else:
Expand Down Expand Up @@ -854,7 +854,7 @@ def _parse_otherwise(
conditions.update(**kwds) # type: ignore[call-arg]
selection.condition = conditions["condition"]
else:
if not isinstance(statement, t.Mapping):
if not isinstance(statement, Mapping):
statement = _parse_literal(statement)
selection = conditions
selection.update(**statement, **kwds) # type: ignore[call-arg]
Expand Down
4 changes: 2 additions & 2 deletions sphinxext/code_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

if TYPE_CHECKING:
import sys
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import Any, Callable, ClassVar, TypeVar, Union
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from typing import Any, ClassVar, TypeVar, Union

from docutils.parsers.rst.states import RSTState, RSTStateMachine
from docutils.statemachine import StringList
Expand Down
4 changes: 2 additions & 2 deletions tests/expr/test_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import operator
import sys
from inspect import classify_class_attrs, getmembers, signature
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
from typing import TYPE_CHECKING, Any, TypeVar, cast

import pytest
from jsonschema.exceptions import ValidationError
Expand All @@ -14,7 +14,7 @@
from altair.expr.core import Expression, GetAttrExpression

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator
from inspect import _IntrospectableCallable

T = TypeVar("T")
Expand Down
5 changes: 4 additions & 1 deletion tests/utils/test_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from pathlib import Path
from typing import Any, Callable, SupportsIndex, TypeVar
from typing import TYPE_CHECKING, Any, SupportsIndex, TypeVar

import narwhals.stable.v1 as nw
import pandas as pd
Expand All @@ -17,6 +17,9 @@
to_values,
)

if TYPE_CHECKING:
from collections.abc import Callable

T = TypeVar("T")


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_plugin_registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable
from collections.abc import Callable

from altair.utils.plugin_registry import PluginRegistry

Expand Down
4 changes: 2 additions & 2 deletions tests/utils/test_schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import warnings
from collections import deque
from functools import partial
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

import jsonschema
import jsonschema.exceptions
Expand All @@ -35,7 +35,7 @@
from vega_datasets import data

if TYPE_CHECKING:
from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence

from narwhals.stable.v1.typing import IntoDataFrame

Expand Down
4 changes: 2 additions & 2 deletions tests/vegalite/v5/test_theme.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

import json
from collections.abc import Mapping, Set
from collections.abc import Callable, Mapping, Set
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, cast, get_args
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast, get_args

import pytest

Expand Down
4 changes: 2 additions & 2 deletions tools/schemapi/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import re
import sys
import textwrap
from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator
from dataclasses import dataclass
from itertools import chain, starmap
from operator import attrgetter
from typing import Any, Callable, ClassVar, Final, Literal, TypeVar, Union
from typing import Any, ClassVar, Final, Literal, TypeVar, Union

from .utils import (
Grouped,
Expand Down
6 changes: 4 additions & 2 deletions tools/update_init_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from __future__ import annotations

import collections.abc as cabc
import typing as t
import typing_extensions as te
from collections.abc import Sequence
from importlib import import_module as _import_module
from importlib.util import find_spec as _find_spec
from inspect import getattr_static, ismodule
Expand All @@ -27,10 +29,10 @@
t.Any,
t.Literal,
t.Union,
t.Iterable,
cabc.Iterable,
t.Protocol,
te.Protocol,
t.Sequence,
Sequence,
t.IO,
annotations,
te.Required,
Expand Down
4 changes: 2 additions & 2 deletions tools/vega_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from itertools import chain
from textwrap import TextWrapper as _TextWrapper
from textwrap import indent
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Literal, overload
from typing import TYPE_CHECKING, Any, ClassVar, Literal, overload

from tools.codemod import ruff
from tools.markup import RSTParse, Token, read_ast_tokens
Expand All @@ -25,7 +25,7 @@

if TYPE_CHECKING:
import sys
from collections.abc import Iterable, Iterator, Mapping, Sequence
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from pathlib import Path
from re import Match, Pattern

Expand Down

0 comments on commit d49f0ff

Please sign in to comment.