diff --git a/altair/vegalite/v5/api.py b/altair/vegalite/v5/api.py index f32ccd631..84a8018d9 100644 --- a/altair/vegalite/v5/api.py +++ b/altair/vegalite/v5/api.py @@ -107,6 +107,8 @@ def _prepare_data(data, context=None): # ------------------------------------------------------------------------ # Aliases & specializations Bin = core.BinParams +Impute = core.ImputeParams +Title = core.TitleParams @utils.use_signature(core.LookupData) diff --git a/tests/vegalite/v5/tests/test_alias.py b/tests/vegalite/v5/tests/test_alias.py new file mode 100644 index 000000000..b9051f13a --- /dev/null +++ b/tests/vegalite/v5/tests/test_alias.py @@ -0,0 +1,21 @@ +import pytest + +import altair.vegalite.v5 as alt + + +def test_aliases(): + """Ensure that any aliases defined in `api.py` aren't colliding with names already defined in `core.py` or `channels.py`.""" + for alias in ["Bin", "Impute", "Title"]: + # this test pass if the alias can resolve to its real name + try: + getattr(alt, alias) + except AttributeError as e: + assert False, f"cannot resolve '{alias}':, {e}" + + # this test fails if the alias match a colliding name in core + with pytest.raises(AttributeError): + getattr(alt.core, alias) + + # this test fails if the alias match a colliding name in channels + with pytest.raises(AttributeError): + getattr(alt.channels, alias)