Skip to content
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
8 changes: 2 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import importlib.metadata
import sys
from contextlib import contextmanager
from datetime import datetime
Expand All @@ -9,11 +10,6 @@

from typing_extensions import Any

try:
import importlib.metadata as importlib_metadata
except ImportError:
import importlib_metadata

try:
from ridgeplot_examples import ALL_EXAMPLES
except ImportError:
Expand All @@ -40,7 +36,7 @@

# -- Project information ---------------------------------------------------------------------------

metadata = importlib_metadata.metadata("ridgeplot")
metadata = importlib.metadata.metadata("ridgeplot")

project = project_name = name = metadata["name"]
author = metadata["author"]
Expand Down
2 changes: 0 additions & 2 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ plugins = numpy.typing.mypy_plugin
;show_traceback = True
;raise_exceptions = True

[mypy-importlib_metadata.*]
ignore_missing_imports = True
[mypy-importlib_resources.*]
ignore_missing_imports = True
[mypy-plotly.*]
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ filterwarnings =
ignore:is_categorical_dtype.*:DeprecationWarning
# Ignore pandas' missing Pyarrow dependency warning
ignore:\nPyarrow will become a required dependency.*:DeprecationWarning
# Ignore Plotly's Kaleido deprecation warning
ignore:\nUse of plotly\.io\.kaleido\.scope.* is deprecated.*:DeprecationWarning
4 changes: 1 addition & 3 deletions src/ridgeplot/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from collections.abc import Collection
from typing import TYPE_CHECKING

from typing_extensions import (
TypeVar,
)
from typing_extensions import TypeVar

if TYPE_CHECKING:
from typing_extensions import Any
Expand Down
26 changes: 16 additions & 10 deletions tests/unit/color/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import re
from typing import TYPE_CHECKING, Any

import pytest
Expand Down Expand Up @@ -45,26 +46,31 @@ def test_to_rgb(color: Color, expected: str) -> None:
("color", "expected_exception", "exception_match"),
[
# invalid types
(1, TypeError, None),
([1, 2, 3], TypeError, None),
(1, TypeError, "Expected str or tuple for color, got <class 'int'> instead"),
([1, 2, 3], TypeError, "Expected str or tuple for color, got <class 'list'> instead"),
# invalid CSS named color
("not-a-color", ValueError, None),
(
"not-a-color",
ValueError,
"color should be a tuple or a str representation of a "
"hex or rgb color, got 'not-a-color' instead",
),
# invalid hex
("#1234567890", ValueError, r"too many values to unpack \(expected 3\)"),
("#ABCDEFGHIJ", ValueError, r"invalid literal for int\(\) with base 16"),
("#1234567890", ValueError, "too many values to unpack (expected 3)"),
("#ABCDEFGHIJ", ValueError, "invalid literal for int() with base 16"),
# invalid rgb
("rgb(0,0,999)", PlotlyError, r"rgb colors tuples cannot exceed 255"),
("rgb(0,0,999)", PlotlyError, "rgb colors tuples cannot exceed 255"),
# invalid tuple
((1, 2), ValueError, r"not enough values to unpack \(expected 3, got 2\)"),
((1, 2, 3, 4), ValueError, r"too many values to unpack \(expected 3\)"),
((1, 2), ValueError, "not enough values to unpack (expected 3, got 2)"),
((1, 2, 3, 4), ValueError, "too many values to unpack (expected 3)"),
],
)
def test_to_rgb_fails_for_invalid_color(
color: Any,
expected_exception: type[Exception],
exception_match: str | None,
exception_match: str,
) -> None:
with pytest.raises(expected_exception, match=exception_match or ""):
with pytest.raises(expected_exception, match=re.escape(exception_match)):
to_rgb(color)


Expand Down
Loading