-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
bugneeds triageIssue that has not been reviewed by xarray team memberIssue that has not been reviewed by xarray team member
Description
What happened?
The following PR:
introduced an unguarded "from typing_extension import Self"
xarray/xarray/core/accessor_dt.py
Line 8 in f1a2c08
from typing_extensions import Self |
whereas in other locations such imports are guarded
Lines 22 to 33 in f1a2c08
try: | |
if sys.version_info >= (3, 11): | |
from typing import Self, TypeAlias | |
else: | |
from typing import TypeAlias | |
from typing_extensions import Self | |
except ImportError: | |
if TYPE_CHECKING: | |
raise | |
else: | |
Self: Any = None |
I've seen this fail on Python 3.11 if typing_extensions
is not manually installed alongside xarray
What did you expect to happen?
No response
Minimal Complete Verifiable Example
On the main branch
$ python
Python 3.11.13 (main, Jun 4 2025, 08:57:30) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xarray
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/simon/code/xarray/xarray/__init__.py", line 3, in <module>
from xarray import coders, groupers, testing, tutorial, ufuncs
File "/home/simon/code/xarray/xarray/groupers.py", line 33, in <module>
from xarray.core.dataarray import DataArray
File "/home/simon/code/xarray/xarray/core/dataarray.py", line 28, in <module>
from xarray.core.accessor_dt import CombinedDatetimelikeAccessor
File "/home/simon/code/xarray/xarray/core/accessor_dt.py", line 8, in <module>
from typing_extensions import Self
ModuleNotFoundError: No module named 'typing_extensions'
>>>
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
Anything else we need to know?
No response
Environment
Metadata
Metadata
Assignees
Labels
bugneeds triageIssue that has not been reviewed by xarray team memberIssue that has not been reviewed by xarray team member