From d95b64adf42fb375642d44fd6553682c4a18d7ad Mon Sep 17 00:00:00 2001 From: Michael duPont Date: Sun, 26 May 2024 20:40:56 -0400 Subject: [PATCH] Fix Self on Py<3.11 --- avwx/base.py | 7 ++++++- avwx/station/station.py | 7 ++++++- pyproject.toml | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/avwx/base.py b/avwx/base.py index 49d7a8d..fafd601 100644 --- a/avwx/base.py +++ b/avwx/base.py @@ -7,7 +7,7 @@ from abc import ABCMeta, abstractmethod from contextlib import suppress from datetime import date, datetime, timezone -from typing import TYPE_CHECKING, Self +from typing import TYPE_CHECKING # module from avwx.exceptions import BadStation @@ -17,6 +17,11 @@ from avwx.service import Service from avwx.structs import ReportData, Units +try: + from typing import Self +except ImportError: + from typing_extensions import Self + def find_station(report: str) -> Station | None: """Returns the first Station found in a report string""" diff --git a/avwx/station/station.py b/avwx/station/station.py index c6f74f4..9a1edfe 100644 --- a/avwx/station/station.py +++ b/avwx/station/station.py @@ -7,7 +7,7 @@ from copy import copy from dataclasses import dataclass from functools import lru_cache -from typing import Any, Self +from typing import Any # library import httpx @@ -19,6 +19,11 @@ from avwx.station.meta import STATIONS from avwx.structs import Coord +try: + from typing import Self +except ImportError: + from typing_extensions import Self + def _get_ip_location() -> Coord: """Return the current location according to ipinfo.io.""" diff --git a/pyproject.toml b/pyproject.toml index aa647db..1432f9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dependencies = [ "geopy>=2.4", "httpx>=0.26", "python-dateutil>=2.8", + "typing-extensions~=4.12; python_version < '3.11'", "xmltodict>=0.13", ]