Skip to content

Commit

Permalink
fix: Define typing as a package to support submodules
Browse files Browse the repository at this point in the history
The usage I described in the description was not actually possible:

>- The top-level object `ThemeConfig` is exported to `altair.typing`> - All others are accessible via `altair.typing.theme`.

This resolves the `ModuleNotFoundError` that would get raised when trying this
  • Loading branch information
dangotbanned committed Sep 16, 2024
1 parent 6e4af95 commit d4bd6db
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions altair/typing.py → altair/typing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"theme",
]

import altair.vegalite.v5.schema._config as theme
from altair.typing import theme
from altair.typing.theme import ThemeConfig
from altair.utils.schemapi import Optional
from altair.vegalite.v5.api import ChartType, is_chart_type
from altair.vegalite.v5.schema._config import ThemeConfig
from altair.vegalite.v5.schema.channels import (
ChannelAngle,
ChannelColor,
Expand Down
1 change: 1 addition & 0 deletions altair/typing/theme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from altair.vegalite.v5.schema._config import * # noqa: F403
2 changes: 1 addition & 1 deletion altair/vegalite/v5/schema/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import TypedDict
else:
from typing_extensions import TypedDict

from ._typing import PaddingKwds, RowColKwds

if TYPE_CHECKING:
# ruff: noqa: F405
Expand Down
1 change: 1 addition & 0 deletions tools/generate_schema_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ def vegalite_main(skip_download: bool = False) -> None:
HEADER,
"from typing import Any, TYPE_CHECKING, Literal, Sequence, TypedDict, Union",
import_typing_extensions((3, 14), "TypedDict", include_sys=True),
f"from ._typing import {ROW_COL_KWDS}, {PADDING_KWDS}",
"\n\n",
import_type_checking("from ._typing import * # noqa: F403"),
"\n\n",
Expand Down

0 comments on commit d4bd6db

Please sign in to comment.