From a42f80c64658344e9fac2087cd2605b546cb0f26 Mon Sep 17 00:00:00 2001 From: spencerwooo Date: Thu, 28 Nov 2024 19:39:41 +0800 Subject: [PATCH] Fix backward compatibility with Python 3.10 --- README.md | 4 ++-- torchattack/__init__.py | 2 +- torchattack/attack_model.py | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c3c58fd..2f25af5 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,13 @@ Install from GitHub source - ```shell -python -m pip install git+https://github.com/spencerwooo/torchattack@v1.0.2 +python -m pip install git+https://github.com/spencerwooo/torchattack@v1.0.3 ``` Install from Gitee mirror - ```shell -python -m pip install git+https://gitee.com/spencerwoo/torchattack@v1.0.2 +python -m pip install git+https://gitee.com/spencerwoo/torchattack@v1.0.3 ``` ## Usage diff --git a/torchattack/__init__.py b/torchattack/__init__.py index ccd4a68..940a049 100644 --- a/torchattack/__init__.py +++ b/torchattack/__init__.py @@ -23,7 +23,7 @@ from torchattack.vmifgsm import VMIFGSM from torchattack.vnifgsm import VNIFGSM -__version__ = '1.0.2' +__version__ = '1.0.3' __all__ = [ # Helper function to create an attack by its name diff --git a/torchattack/attack_model.py b/torchattack/attack_model.py index 9cd3806..528dc77 100644 --- a/torchattack/attack_model.py +++ b/torchattack/attack_model.py @@ -1,4 +1,9 @@ -from typing import Callable, Self +from typing import Callable + +try: + from typing import Self +except ImportError: + from typing_extensions import Self import torch import torch.nn as nn