diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-08 09:22:17 -0800 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-11-08 09:22:17 -0800 |
| commit | 51798a18eaa5c7b7d45ecf4a9f286db9e95fef48 (patch) | |
| tree | fb717e0cad19103f52e7f60921c5a92fa963bdeb | |
| parent | 088f0663e37bac29d0f5fa4f1261f1e7a211e28a (diff) | |
| download | wikiget-51798a18eaa5c7b7d45ecf4a9f286db9e95fef48.tar.gz wikiget-51798a18eaa5c7b7d45ecf4a9f286db9e95fef48.zip | |
Conditionally import modules used for type checking
| -rw-r--r-- | pyproject.toml | 1 | ||||
| -rw-r--r-- | src/wikiget/parse.py | 5 | ||||
| -rw-r--r-- | tests/test_parse.py | 8 | ||||
| -rw-r--r-- | tests/test_validations.py | 7 |
4 files changed, 16 insertions, 5 deletions
diff --git a/pyproject.toml b/pyproject.toml index e7ecdd8..5681dc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -143,6 +143,7 @@ select = [ "RUF", "S", "T", + "TCH", "TID", "UP", "W", diff --git a/src/wikiget/parse.py b/src/wikiget/parse.py index 99cb01c..82e9172 100644 --- a/src/wikiget/parse.py +++ b/src/wikiget/parse.py @@ -19,7 +19,7 @@ from __future__ import annotations import fileinput import logging -from argparse import Namespace +from typing import TYPE_CHECKING from urllib.parse import unquote, urlparse import wikiget @@ -27,6 +27,9 @@ from wikiget.exceptions import ParseError from wikiget.file import File from wikiget.validations import valid_file +if TYPE_CHECKING: + from argparse import Namespace + logger = logging.getLogger(__name__) diff --git a/tests/test_parse.py b/tests/test_parse.py index e3bef2d..7ef182c 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -19,15 +19,19 @@ from __future__ import annotations import io import logging -from pathlib import Path +from typing import TYPE_CHECKING import pytest from wikiget.exceptions import ParseError -from wikiget.file import File from wikiget.parse import get_dest, read_batch_file from wikiget.wikiget import parse_args +if TYPE_CHECKING: + from pathlib import Path + + from wikiget.file import File + class TestGetDest: @pytest.fixture() diff --git a/tests/test_validations.py b/tests/test_validations.py index a8fbf1b..5263cdc 100644 --- a/tests/test_validations.py +++ b/tests/test_validations.py @@ -17,13 +17,16 @@ from __future__ import annotations -from pathlib import Path -from re import Match +from typing import TYPE_CHECKING import pytest from wikiget.validations import valid_file, valid_site, verify_hash +if TYPE_CHECKING: + from pathlib import Path + from re import Match + class TestSiteInput: @pytest.fixture( |
