From 7bddc05262d10cb719b8307785ab46d48d0ce9b8 Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 9 Sep 2024 15:13:47 +0200 Subject: [PATCH] Use typing-extensions for python < 3.11 --- pyproject.toml | 1 + xarray_ms/backend/msv2/encoders.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 642b559..613161a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ dask = {version = "^2024.5.0", optional = true, extras = ["testing"]} distributed = {version = "^2024.5.0", optional = true, extras = ["testing"]} cacheout = "^0.16.0" arcae = "^0.2.4" +typing-extensions = { version = "^4.12.2", python = "<3.11" } [tool.poetry.extras] testing = ["dask", "distributed", "pytest"] diff --git a/xarray_ms/backend/msv2/encoders.py b/xarray_ms/backend/msv2/encoders.py index cb24f59..fac345c 100644 --- a/xarray_ms/backend/msv2/encoders.py +++ b/xarray_ms/backend/msv2/encoders.py @@ -13,8 +13,16 @@ from __future__ import annotations +import sys from datetime import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Self +from typing import TYPE_CHECKING, Any, Dict, List + +if TYPE_CHECKING: + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self + import numpy as np import numpy.testing as npt