Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ruff): Fix 0.9.2 lints #3771

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion altair/utils/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from typing import Never, Self
else:
from typing_extensions import Never, Self
_OptionalModule: TypeAlias = "ModuleType | None" # noqa: TC008
_OptionalModule: TypeAlias = "ModuleType | None"

ValidationErrorList: TypeAlias = list[jsonschema.exceptions.ValidationError]
GroupedValidationErrors: TypeAlias = dict[str, ValidationErrorList]
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from _pytest.mark import ParameterSet

MarksType: TypeAlias = (
"pytest.MarkDecorator | Collection[pytest.MarkDecorator | pytest.Mark]" # noqa: TC008
"pytest.MarkDecorator | Collection[pytest.MarkDecorator | pytest.Mark]"
)


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _check(arr, typ):
_check(nulled, "quantitative")
_check(["a", "b", "c"], "nominal")

with pytest.warns(UserWarning):
with pytest.warns(UserWarning, match=r"infer vegalite type"):
_check([], "nominal")


Expand Down
24 changes: 13 additions & 11 deletions tests/vegalite/v5/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def chart():
return alt.Chart("data.csv").mark_point()


def test_html_renderer_embed_options(chart, renderer="html"):
def test_html_renderer_embed_options(chart):
"""Test that embed_options in renderer metadata are correctly manifest in html."""
# Short of parsing the javascript, it's difficult to parse out the
# actions. So we use string matching
Expand All @@ -45,7 +45,7 @@ def assert_has_options(chart, **opts):
for key, val in opts.items():
assert json.dumps({key: val})[1:-1] in html

with alt.renderers.enable(renderer):
with alt.renderers.enable("html"):
assert_has_options(chart, mode="vega-lite")

with alt.renderers.enable(embed_options={"actions": {"export": True}}):
Expand All @@ -55,11 +55,13 @@ def assert_has_options(chart, **opts):
assert_has_options(chart, mode="vega-lite", actions=True)


def test_mimetype_renderer_embed_options(chart, renderer="mimetype"):
def test_mimetype_renderer_embed_options(chart):
# check that metadata is passed appropriately
mimetype = alt.display.VEGALITE_MIME_TYPE
from altair.vegalite.v5.display import VEGALITE_MIME_TYPE

mimetype = VEGALITE_MIME_TYPE
spec = chart.to_dict()
with alt.renderers.enable(renderer):
with alt.renderers.enable("mimetype"):
# Sanity check: no metadata specified
bundle, metadata = chart._repr_mimebundle_(None, None)
assert bundle[mimetype] == spec
Expand All @@ -71,11 +73,11 @@ def test_mimetype_renderer_embed_options(chart, renderer="mimetype"):
assert metadata == {mimetype: {"embed_options": {"actions": False}}}


def test_json_renderer_embed_options(chart, renderer="json"):
def test_json_renderer_embed_options(chart):
"""Test that embed_options in renderer metadata are correctly manifest in html."""
mimetype = "application/json"
spec = chart.to_dict()
with alt.renderers.enable(renderer):
with alt.renderers.enable("json"):
# Sanity check: no options specified
bundle, metadata = chart._repr_mimebundle_(None, None)
assert bundle[mimetype] == spec
Expand All @@ -89,12 +91,12 @@ def test_json_renderer_embed_options(chart, renderer="json"):


@skip_requires_vl_convert
def test_renderer_with_none_embed_options(chart, renderer="mimetype"):
def test_renderer_with_none_embed_options(chart):
# Check that setting embed_options to None doesn't crash
from altair.utils.mimebundle import spec_to_mimebundle

spec = chart.to_dict()
with alt.renderers.enable(renderer, embed_options=None):
with alt.renderers.enable("mimetype", embed_options=None):
bundle = spec_to_mimebundle(
spec=spec,
mode="vega-lite",
Expand All @@ -105,9 +107,9 @@ def test_renderer_with_none_embed_options(chart, renderer="mimetype"):


@jupyter_marks
def test_jupyter_renderer_mimetype(chart, renderer="jupyter") -> None:
def test_jupyter_renderer_mimetype(chart) -> None:
"""Test that we get the expected widget mimetype when the jupyter renderer is enabled."""
with alt.renderers.enable(renderer):
with alt.renderers.enable("jupyter"):
assert (
"application/vnd.jupyter.widget-view+json"
in chart._repr_mimebundle_(None, None)[0]
Expand Down
2 changes: 1 addition & 1 deletion tools/schemapi/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
from typing import Never, Self
else:
from typing_extensions import Never, Self
_OptionalModule: TypeAlias = "ModuleType | None" # noqa: TC008
_OptionalModule: TypeAlias = "ModuleType | None"

ValidationErrorList: TypeAlias = list[jsonschema.exceptions.ValidationError]
GroupedValidationErrors: TypeAlias = dict[str, ValidationErrorList]
Expand Down
Loading