diff --git a/apypie/action.py b/apypie/action.py index 9d3f27e..7d09c66 100644 --- a/apypie/action.py +++ b/apypie/action.py @@ -4,6 +4,8 @@ from __future__ import print_function, absolute_import +from typing import Optional, Any, Iterable, List, TYPE_CHECKING # pylint: disable=unused-import # noqa: F401 + from apypie.route import Route from apypie.example import Example from apypie.param import Param @@ -14,13 +16,8 @@ except NameError: # Python 3 has no basestring basestring = str # pylint: disable=invalid-name,redefined-builtin -try: - from typing import Optional, Any, Iterable, List, TYPE_CHECKING # pylint: disable=unused-import -except ImportError: - TYPE_CHECKING = False - if TYPE_CHECKING: - from apypie.api import Api # pylint: disable=cyclic-import,unused-import + from apypie.api import Api # pylint: disable=cyclic-import,unused-import # noqa: F401 class Action(object): diff --git a/apypie/api.py b/apypie/api.py index 8450271..98c6bf4 100644 --- a/apypie/api.py +++ b/apypie/api.py @@ -7,25 +7,18 @@ import errno import glob import json -try: - from json.decoder import JSONDecodeError # type: ignore -except ImportError: - JSONDecodeError = ValueError # type: ignore +from json.decoder import JSONDecodeError # type: ignore import os -try: - from urlparse import urljoin # type: ignore -except ImportError: - from urllib.parse import urljoin # type: ignore +from urllib.parse import urljoin # type: ignore import requests from apypie.resource import Resource from apypie.exceptions import DocLoadingError -try: - from typing import Any, Iterable, Optional # pylint: disable=unused-import - from apypie.action import Action # pylint: disable=unused-import -except ImportError: - pass +from typing import Any, Iterable, Optional, TYPE_CHECKING # pylint: disable=unused-import # noqa: F401 + +if TYPE_CHECKING: + from apypie.action import Action # pylint: disable=unused-import # noqa: F401 NO_CONTENT = 204 diff --git a/apypie/foreman.py b/apypie/foreman.py index 276a558..4e0d388 100644 --- a/apypie/foreman.py +++ b/apypie/foreman.py @@ -5,14 +5,11 @@ """ import time -try: - from typing import cast, Optional, Set, Tuple -except ImportError: - pass +from typing import cast, Optional, Set, Tuple from apypie.api import Api -from apypie.resource import Resource # pylint: disable=unused-import +from apypie.resource import Resource # pylint: disable=unused-import # noqa: F401 # Foreman supports "per_page=all" since 2.2 (https://projects.theforeman.org/issues/29909) # But plugins, especially Katello, do not: https://github.com/Katello/katello/pull/11126 diff --git a/apypie/inflector.py b/apypie/inflector.py index 428e373..529f956 100644 --- a/apypie/inflector.py +++ b/apypie/inflector.py @@ -7,10 +7,7 @@ import re -try: - from typing import Iterable, Tuple # pylint: disable=unused-import -except ImportError: - pass +from typing import Iterable, Tuple # pylint: disable=unused-import # noqa: F401 class Inflections(object): diff --git a/apypie/resource.py b/apypie/resource.py index 8afd702..91fab00 100644 --- a/apypie/resource.py +++ b/apypie/resource.py @@ -4,15 +4,12 @@ from __future__ import print_function, absolute_import -from apypie.action import Action +from typing import Optional, Any, List, TYPE_CHECKING # pylint: disable=unused-import # noqa: F401 -try: - from typing import Optional, Any, List, TYPE_CHECKING # pylint: disable=unused-import -except ImportError: - TYPE_CHECKING = False +from apypie.action import Action if TYPE_CHECKING: - from apypie.api import Api # pylint: disable=cyclic-import,unused-import + from apypie.api import Api # pylint: disable=cyclic-import,unused-import # noqa: F401 class Resource(object): diff --git a/apypie/route.py b/apypie/route.py index 6fe5bf3..a2bff7d 100644 --- a/apypie/route.py +++ b/apypie/route.py @@ -4,15 +4,9 @@ from __future__ import print_function, absolute_import -try: - from urllib.parse import quote # type: ignore -except ImportError: - from urllib import quote # type: ignore - -try: - from typing import List, Optional # pylint: disable=unused-import -except ImportError: - pass +from urllib.parse import quote # type: ignore + +from typing import List, Optional # pylint: disable=unused-import # noqa: F401 class Route(object):