vega / altair

Declarative statistical visualization library for Python
https://altair-viz.github.io/
BSD 3-Clause "New" or "Revised" License
9.39k stars 795 forks source link

TypeError on Import - TypeError: _TypedDictMeta.__new__() got an unexpected keyword argument 'closed' #3684

Open abdullahau opened 5 days ago

abdullahau commented 5 days ago

What happened?

I am trying to import atlair on my jupyter notebook in vscode. I have a virtual environment of Python 3.13 running where I have installed atlair with all its optional dependencies. However, as I try to import Atlair as following:

import altair as alt

I get the following error:

TypeError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 import altair as alt

File ~/Documents/Coding-Projects/.venv/lib/python3.13/site-packages/altair/__init__.py:650
    646 def __dir__():
    647     return __all__
--> 650 from altair.vegalite import *
    651 from altair.vegalite.v5.schema.core import Dict
    652 from altair.jupyter import JupyterChart

File ~/Documents/Coding-Projects/.venv/lib/python3.13/site-packages/altair/vegalite/__init__.py:2
      1 # ruff: noqa: F403
----> 2 from .v5 import *

File ~/Documents/Coding-Projects/.venv/lib/python3.13/site-packages/altair/vegalite/v5/__init__.py:4
      1 # ruff: noqa: F401, F403
      2 from altair.expr.core import datum
----> 4 from .api import *
      5 from .compiler import vegalite_compilers
      6 from .data import (
      7     MaxRowsError,
      8     data_transformers,
   (...)
     14     to_values,
     15 )

File ~/Documents/Coding-Projects/.venv/lib/python3.13/site-packages/altair/vegalite/v5/api.py:618
    614         raise TypeError(if_false)
    615     return selection
--> 618 class _ConditionClosed(TypedDict, closed=True, total=False):  # type: ignore[call-arg]
    619     # https://peps.python.org/pep-0728/
    620     # Parameter {"param", "value", "empty"}
    621     # Predicate {"test", "value"}
    622     empty: Optional[bool]
    623     param: Parameter | str

TypeError: _TypedDictMeta.__new__() got an unexpected keyword argument 'closed'

What would you like to happen instead?

No response

Which version of Altair are you using?

altair==5.4.1

jgunstone commented 4 days ago

also getting this issue FYI issue persists in altair==5.4.0 but is not present in altair==5.3

abdullahau commented 4 days ago

@jgunstone I downloaded the Altair source repo and installed the package directly. The issue was resolved, and Altair has been working fine since yesterday.

jgunstone commented 4 days ago

@jgunstone I downloaded the Altair source repo and installed the packed directly. The issue was resolved, and Altair has been working fine since yesterday.

as in the issue has been fixed in the main branch but hasn't been released yet?

raethlein commented 4 days ago

I believe it is due to Python 3.13 and, if so, a duplicate of https://github.com/vega/altair/issues/3620, which was fixed in https://github.com/vega/altair/pull/3591.

Does someone know a rough timeline for the next release of 5.5 which will support Python 3.13? 🙂

dangotbanned commented 1 day ago

I believe it is due to Python 3.13 and, if so, a duplicate of #3620, which was fixed in #3591.

Does someone know a rough timeline for the next release of 5.5 which will support Python 3.13? 🙂

@raethlein I've opened a discussion on this now in:

Hopefully that should make this easier to track 👍