mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-06 12:27:45 +00:00
Drop Python 2.7 support (#1058)
* Drop 2.7 * fixup! Drop 2.7 * fixup! Drop 2.7
This commit is contained in:
committed by
Henning Jacobs
parent
e06ec6da82
commit
ec37d03902
@@ -1,6 +1,5 @@
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.6"
|
||||
- "3.7"
|
||||
- "3.8"
|
||||
|
||||
@@ -99,7 +99,7 @@ How to Use
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
Python 2.7 or Python 3.6+
|
||||
Python 3.6+
|
||||
|
||||
Installing It
|
||||
-------------
|
||||
|
||||
@@ -37,7 +37,7 @@ class RequestResponseDecorator(BaseDecorator):
|
||||
:type function: types.FunctionType
|
||||
:rtype: types.FunctionType
|
||||
"""
|
||||
if has_coroutine(function, self.api): # pragma: 2.7 no cover
|
||||
if has_coroutine(function, self.api):
|
||||
from .coroutine_wrappers import get_request_life_cycle_wrapper
|
||||
wrapper = get_request_life_cycle_wrapper(function, self.api, self.mimetype)
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class ResponseValidator(BaseDecorator):
|
||||
|
||||
return response
|
||||
|
||||
if has_coroutine(function): # pragma: 2.7 no cover
|
||||
if has_coroutine(function):
|
||||
from .coroutine_wrappers import get_response_validator_wrapper
|
||||
wrapper = get_response_validator_wrapper(function, _wrapper)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import functools
|
||||
import logging
|
||||
|
||||
from connexion.resolver import Resolution, Resolver, ResolverError
|
||||
@@ -5,17 +6,6 @@ from connexion.resolver import Resolution, Resolver, ResolverError
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def partial(func, **frozen):
|
||||
"""
|
||||
Replacement for functools.partial as functools.partial does not work with inspect.py on Python 2.7
|
||||
"""
|
||||
def wrapper(*args, **kwargs):
|
||||
for k, v in frozen.items():
|
||||
kwargs[k] = v
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
class MockResolver(Resolver):
|
||||
|
||||
def __init__(self, mock_all):
|
||||
@@ -35,7 +25,7 @@ class MockResolver(Resolver):
|
||||
operation_id = 'mock-{}'.format(self._operation_id_counter)
|
||||
self._operation_id_counter += 1
|
||||
|
||||
mock_func = partial(self.mock_operation, operation=operation)
|
||||
mock_func = functools.partial(self.mock_operation, operation=operation)
|
||||
if self.mock_all:
|
||||
func = mock_func
|
||||
else:
|
||||
|
||||
@@ -194,28 +194,24 @@ def has_coroutine(function, api=None):
|
||||
If ``function`` is a decorator (has a ``__wrapped__`` attribute)
|
||||
this function will also look at the wrapped function.
|
||||
"""
|
||||
if six.PY3: # pragma: 2.7 no cover
|
||||
import asyncio
|
||||
import asyncio
|
||||
|
||||
def iscorofunc(func):
|
||||
def iscorofunc(func):
|
||||
iscorofunc = asyncio.iscoroutinefunction(func)
|
||||
while not iscorofunc and hasattr(func, '__wrapped__'):
|
||||
func = func.__wrapped__
|
||||
iscorofunc = asyncio.iscoroutinefunction(func)
|
||||
while not iscorofunc and hasattr(func, '__wrapped__'):
|
||||
func = func.__wrapped__
|
||||
iscorofunc = asyncio.iscoroutinefunction(func)
|
||||
return iscorofunc
|
||||
return iscorofunc
|
||||
|
||||
if api is None:
|
||||
return iscorofunc(function)
|
||||
if api is None:
|
||||
return iscorofunc(function)
|
||||
|
||||
else:
|
||||
return any(
|
||||
iscorofunc(func) for func in (
|
||||
function, api.get_request, api.get_response
|
||||
)
|
||||
else:
|
||||
return any(
|
||||
iscorofunc(func) for func in (
|
||||
function, api.get_request, api.get_response
|
||||
)
|
||||
else: # pragma: 3 no cover
|
||||
# there's no asyncio in python 2
|
||||
return False
|
||||
)
|
||||
|
||||
|
||||
def yamldumper(openapi):
|
||||
|
||||
@@ -5,7 +5,7 @@ Quickstart
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
Python 2.7 or Python 3.5+
|
||||
Python 3.6+
|
||||
|
||||
Installing It
|
||||
-------------
|
||||
|
||||
@@ -6,4 +6,3 @@ omit = connexion/apis/aiohttp_api.py
|
||||
[report]
|
||||
exclude_lines =
|
||||
pragma: no cover
|
||||
pragma: 2.7 no cover
|
||||
|
||||
1
setup.py
1
setup.py
@@ -117,7 +117,6 @@ setup(
|
||||
test_suite='tests',
|
||||
classifiers=[
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
from connexion.mock import MockResolver, partial
|
||||
from connexion.mock import MockResolver
|
||||
from connexion.operations import Swagger2Operation
|
||||
|
||||
|
||||
def test_partial():
|
||||
def func(a, b):
|
||||
return a + b
|
||||
|
||||
add_three = partial(func, a=3)
|
||||
assert add_three(b=1) == 4
|
||||
|
||||
|
||||
def test_mock_resolver():
|
||||
resolver = MockResolver(mock_all=True)
|
||||
|
||||
|
||||
2
tox.ini
2
tox.ini
@@ -4,7 +4,6 @@ exclude=connexion/__init__.py
|
||||
|
||||
[tox]
|
||||
envlist =
|
||||
{py27}-{min,pypi,dev}
|
||||
{py36}-{min,pypi,dev}
|
||||
{py37}-{min,pypi,dev}
|
||||
{py38}-{min,pypi,dev}
|
||||
@@ -14,7 +13,6 @@ envlist =
|
||||
flake8
|
||||
|
||||
[travis]
|
||||
2.7=py27-min,py27-pypi
|
||||
3.6=py36-min,py36-pypi
|
||||
3.7=py37-min,py37-pypi,isort-check,isort-check-examples,isort-check-tests,flake8
|
||||
3.8=py38-min
|
||||
|
||||
Reference in New Issue
Block a user