Skip to content

Commit 426b5de

Browse files
committed
[core] removed imports of deprecated typing aliases
A bunch of types in the typing module are deprecated since 3.9 and due for possible removal after the release of 3.14 (e.g. Iterable, Generator, Callable). Imports were updated to point to the new types in collections.abc to future proof the code.
1 parent 3eb960d commit 426b5de

File tree

8 files changed

+18
-9
lines changed

8 files changed

+18
-9
lines changed

src/geocompy/communication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import logging
2929
from types import TracebackType
30-
from typing import Generator
30+
from collections.abc import Generator
3131
from contextlib import contextmanager
3232
from abc import ABC, abstractmethod
3333
from time import sleep

src/geocompy/data.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
from enum import Enum
3131
from typing import (
3232
Literal,
33-
Callable,
34-
Iterator,
3533
TypeVar,
3634
Self,
3735
Any,
3836
SupportsFloat
3937
)
38+
from collections.abc import (
39+
Callable,
40+
Iterator
41+
)
4042

4143

4244
RO = 180 * 60 * 60 / math.pi

src/geocompy/geo/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
from traceback import format_exc
4242
from time import sleep
4343
from enum import Enum
44-
from typing import Any, Callable, Iterable, overload, TypeVar
44+
from typing import Any, overload, TypeVar
45+
from collections.abc import Callable, Iterable
4546

4647
from serial import SerialException, SerialTimeoutException
4748

src/geocompy/geo/gctypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from __future__ import annotations
1919

2020
from enum import IntEnum, Enum
21-
from typing import TypeVar, Any, Generic, Callable, Iterable, overload
21+
from typing import TypeVar, Any, Generic, overload
22+
from collections.abc import Callable, Iterable
2223
from abc import ABC, abstractmethod
2324

2425
from ..data import Angle, Byte

src/geocompy/gsi/dna/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
from enum import IntEnum
2424
import re
25-
from typing import Callable, TypeVar
25+
from typing import TypeVar
26+
from collections.abc import Callable
2627
from traceback import format_exc
2728
from logging import Logger
2829
from time import sleep

src/geocompy/gsi/gsiformat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
Self,
2929
TypeVar,
3030
TextIO,
31+
)
32+
from collections.abc import (
3133
Iterator,
3234
Iterable,
3335
Generator
@@ -2259,7 +2261,7 @@ def get_word(self, wordtype: type[_T]) -> _T | None:
22592261
Return None if the block does not contain a word of the requested
22602262
type.
22612263
"""
2262-
return cast(_T, self._words.get(wordtype.WI()))
2264+
return cast(_T | None, self._words.get(wordtype.WI()))
22632265

22642266
def serialize(
22652267
self,

src/geocompy/gsi/gsitypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from __future__ import annotations
1818

1919
from abc import ABC, abstractmethod
20-
from typing import TypeVar, Generic, Callable, Literal
20+
from typing import TypeVar, Generic, Literal
21+
from collections.abc import Callable
2122

2223
from .gsiformat import GsiWord
2324

tests/test_geocom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Callable, Any, Iterable
1+
from typing import Any
2+
from collections.abc import Callable, Iterable
23
import re
34

45
import pytest

0 commit comments

Comments
 (0)