Skip to content

Commit

Permalink
Move not_installed_error into utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwann committed Jul 7, 2021
1 parent d8dfd6c commit b69d0d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
10 changes: 1 addition & 9 deletions connexion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@
from .operations import compat
from .problem import problem # NOQA
from .resolver import Resolution, Resolver, RestyResolver # NOQA
from .utils import not_installed_error # NOQA

full_name = '{}.operation'.format(__package__)
sys.modules[full_name] = sys.modules[compat.__name__]


def not_installed_error(exc): # pragma: no cover
import functools

def _required_lib(exc, *args, **kwargs):
raise exc

return functools.partial(_required_lib, exc)


try:
from flask import request # NOQA

Expand Down
10 changes: 1 addition & 9 deletions connexion/security/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
from .async_security_handler_factory import AbstractAsyncSecurityHandlerFactory # NOQA
from .security_handler_factory import AbstractSecurityHandlerFactory # NOQA


def not_installed_error(exc): # pragma: no cover
import functools

def _required_lib(exc, *args, **kwargs):
raise exc

return functools.partial(_required_lib, exc)

from ..utils import not_installed_error

# concrete
try:
Expand Down
9 changes: 9 additions & 0 deletions connexion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,12 @@ def ignore_aliases(self, *args):
yaml.representer.SafeRepresenter.represent_scalar = my_represent_scalar

return yaml.dump(openapi, allow_unicode=True, Dumper=NoAnchorDumper)


def not_installed_error(exc): # pragma: no cover
"""Raises the ImportError when the module/object is actually called."""

def _required_lib(exc, *args, **kwargs):
raise exc

return functools.partial(_required_lib, exc)

0 comments on commit b69d0d6

Please sign in to comment.