diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-16 12:29:36 -0800 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-11-16 12:29:36 -0800 |
| commit | 06dfda7b5430bfc895a39defad50f184d41281f1 (patch) | |
| tree | 858948a451305a117678f6047f1a6b9ab714f72b | |
| parent | dbb8dd8a3ba3e5bd65edae2aded253975708dc13 (diff) | |
| download | wikiget-06dfda7b5430bfc895a39defad50f184d41281f1.tar.gz wikiget-06dfda7b5430bfc895a39defad50f184d41281f1.zip | |
Additional type checking import blocks
| -rw-r--r-- | src/wikiget/client.py | 10 | ||||
| -rw-r--r-- | src/wikiget/file.py | 8 | ||||
| -rw-r--r-- | tests/conftest.py | 10 | ||||
| -rw-r--r-- | tests/test_client.py | 2 | ||||
| -rw-r--r-- | tests/test_file_class.py | 2 | ||||
| -rw-r--r-- | tests/test_logging.py | 8 | ||||
| -rw-r--r-- | tests/test_wikiget_cli.py | 2 |
7 files changed, 34 insertions, 8 deletions
diff --git a/src/wikiget/client.py b/src/wikiget/client.py index 2fc4a6c..64c14d9 100644 --- a/src/wikiget/client.py +++ b/src/wikiget/client.py @@ -15,15 +15,21 @@ # You should have received a copy of the GNU General Public License # along with Wikiget. If not, see <https://www.gnu.org/licenses/>. +from __future__ import annotations + import logging -from argparse import Namespace +from typing import TYPE_CHECKING from mwclient import APIError, InvalidResponse, LoginError, Site -from mwclient.image import Image from requests import ConnectionError, HTTPError import wikiget +if TYPE_CHECKING: + from argparse import Namespace + + from mwclient.image import Image + logger = logging.getLogger(__name__) diff --git a/src/wikiget/file.py b/src/wikiget/file.py index a362aff..6fc03a1 100644 --- a/src/wikiget/file.py +++ b/src/wikiget/file.py @@ -15,12 +15,16 @@ # You should have received a copy of the GNU General Public License # along with Wikiget. If not, see <https://www.gnu.org/licenses/>. -from pathlib import Path +from __future__ import annotations -from mwclient.image import Image +from pathlib import Path +from typing import TYPE_CHECKING from wikiget import DEFAULT_SITE +if TYPE_CHECKING: + from mwclient.image import Image + class File: """A file object.""" diff --git a/tests/conftest.py b/tests/conftest.py index 6088029..128b581 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,13 +17,19 @@ """Define fixtures used across all tests in this folder.""" -from pathlib import Path +from __future__ import annotations + +from typing import TYPE_CHECKING import pytest -import requests_mock as rm from wikiget.file import File +if TYPE_CHECKING: + from pathlib import Path + + import requests_mock as rm + # 2x2 JPEG TEST_FILE_BYTES = ( b"\xff\xd8\xff\xdb\x00C\x00\x03\x02\x02\x02\x02\x02\x03\x02\x02\x02\x03\x03\x03\x03" diff --git a/tests/test_client.py b/tests/test_client.py index dae63f5..a0e4855 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -17,6 +17,8 @@ """Define tests related to the wikiget.client module.""" +from __future__ import annotations + import logging from unittest.mock import MagicMock, patch, sentinel diff --git a/tests/test_file_class.py b/tests/test_file_class.py index 4ad06d1..699f40d 100644 --- a/tests/test_file_class.py +++ b/tests/test_file_class.py @@ -17,6 +17,8 @@ """Define tests related to the wikiget.file module.""" +from __future__ import annotations + from wikiget import DEFAULT_SITE from wikiget.file import File diff --git a/tests/test_logging.py b/tests/test_logging.py index 8d58cdf..a402120 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -17,14 +17,18 @@ """Define tests related to the wikiget.logging module.""" +from __future__ import annotations + import logging from pathlib import Path - -import pytest +from typing import TYPE_CHECKING from wikiget.logging import FileLogAdapter, configure_logging from wikiget.wikiget import parse_args +if TYPE_CHECKING: + import pytest + class TestLogging: """Define tests related to wikiget.logging.configure_logging and FileLogAdapter.""" diff --git a/tests/test_wikiget_cli.py b/tests/test_wikiget_cli.py index 28c4399..87bc069 100644 --- a/tests/test_wikiget_cli.py +++ b/tests/test_wikiget_cli.py @@ -17,6 +17,8 @@ """Define tests related to the wikiget.wikiget module.""" +from __future__ import annotations + import logging from unittest.mock import MagicMock, patch |
