Skip to content

Commit 926be31

Browse files
refactor: Stop using deprecated typing classes (#353)
* Use Iterable, Sequence, Hashable, Callable from collections.abc rather than typing * Use contextlib.AbstractContextManager rather than typing.ContextManager typing.Iterable, typing.Sequence, typing.Callable and typing.ContextManager are deprecated since Python 3.9. typing.Hashable is not deprecated but it's an alias for collections.abc.Hashable, so it's better to use the latter. Note that typing.TypeAlias is also deprecated, but only since Python 3.12, in favor of using the type statement. We can only make the change when we drop support for Python 3.10 and 3.11. --------- Co-authored-by: Valérian Rey <[email protected]>
1 parent 75b8bf8 commit 926be31

File tree

16 files changed

+22
-18
lines changed

16 files changed

+22
-18
lines changed

src/torchjd/_autojac/_backward.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterable, Sequence
1+
from collections.abc import Iterable, Sequence
22

33
from torch import Tensor
44

src/torchjd/_autojac/_mtl_backward.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterable, Sequence
1+
from collections.abc import Iterable, Sequence
22

33
from torch import Tensor
44

src/torchjd/_autojac/_transform/_aggregate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import OrderedDict
2-
from typing import Hashable, TypeVar
2+
from collections.abc import Hashable
3+
from typing import TypeVar
34

45
import torch
56
from torch import Tensor

src/torchjd/_autojac/_transform/_base.py

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

33
from abc import ABC, abstractmethod
4-
from typing import Generic, Sequence
4+
from collections.abc import Sequence
5+
from typing import Generic
56

67
from torch import Tensor
78

src/torchjd/_autojac/_transform/_differentiate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from abc import ABC, abstractmethod
2-
from typing import Sequence
2+
from collections.abc import Sequence
33

44
from torch import Tensor
55

src/torchjd/_autojac/_transform/_grad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
import torch
44
from torch import Tensor

src/torchjd/_autojac/_transform/_jac.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import math
2+
from collections.abc import Callable, Sequence
23
from functools import partial
34
from itertools import accumulate
4-
from typing import Callable, Sequence
55

66
import torch
77
from torch import Size, Tensor

src/torchjd/_autojac/_transform/_materialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
import torch
44
from torch import Tensor

src/torchjd/_autojac/_transform/_ordered_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import OrderedDict
2-
from collections.abc import Set
3-
from typing import Hashable, Iterable, TypeVar
2+
from collections.abc import Hashable, Iterable, Set
3+
from typing import TypeVar
44

55
_KeyType = TypeVar("_KeyType", bound=Hashable)
66

src/torchjd/_autojac/_transform/_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
import torch
44
from torch import Tensor

0 commit comments

Comments
 (0)