Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop catching ImportError after having dropped Python 2 compat #182

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions apypie/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,14 +16,9 @@
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

Check warning on line 21 in apypie/action.py

View check run for this annotation

Codecov / codecov/patch

apypie/action.py#L20-L21

Added lines #L20 - L21 were not covered by tests

class Action(object):
"""
Expand Down
19 changes: 6 additions & 13 deletions apypie/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions apypie/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions apypie/inflector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 3 additions & 6 deletions apypie/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 12 in apypie/resource.py

View check run for this annotation

Codecov / codecov/patch

apypie/resource.py#L12

Added line #L12 was not covered by tests


class Resource(object):
Expand Down
12 changes: 3 additions & 9 deletions apypie/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down