Skip to content

Commit 87c9f85

Browse files
committed
Python2 support drop
1 parent 23a8b57 commit 87c9f85

39 files changed

+112
-170
lines changed

.github/workflows/python-publish.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ on:
1212
jobs:
1313
publish:
1414
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
python-version: [2.7, 3.6]
1815
steps:
1916
- uses: actions/checkout@v2
20-
- name: Set up Python ${{ matrix.python-version }}
17+
- name: Set up Python
2118
uses: actions/setup-python@v2
2219
with:
23-
python-version: ${{ matrix.python-version }}
20+
python-version: '3.x'
2421
- name: Install dependencies
2522
run: |
2623
python -m pip install --upgrade pip

.github/workflows/python-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
16+
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
1717
fail-fast: false
1818
steps:
1919
- uses: actions/checkout@v2

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: python
22
sudo: false
33
matrix:
44
include:
5-
- python: 2.7
65
- python: 3.5
76
- python: 3.6
87
- python: 3.7

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ include LICENSE
22
include README.rst
33
include requirements.txt
44
include requirements_dev.txt
5-
include requirements_2.7.txt

openapi_core/casting/schemas/util.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""OpenAPI core casting schemas util module"""
22
from distutils.util import strtobool
3-
from six import string_types
43

54

65
def forcebool(val):
7-
if isinstance(val, string_types):
6+
if isinstance(val, str):
87
val = strtobool(val)
98

109
return bool(val)

openapi_core/compat.py

-12
This file was deleted.

openapi_core/contrib/django/requests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""OpenAPI core contrib django requests module"""
22
import re
33

4-
from six.moves.urllib.parse import urljoin
4+
from urllib.parse import urljoin
55

66
from openapi_core.contrib.django.compat import (
77
get_request_headers, get_current_scheme_host,

openapi_core/contrib/flask/requests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""OpenAPI core contrib flask requests module"""
22
import re
33

4-
from six.moves.urllib.parse import urljoin
4+
from urllib.parse import urljoin
55

66
from openapi_core.validation.request.datatypes import (
77
RequestParameters, OpenAPIRequest,

openapi_core/contrib/requests/requests.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""OpenAPI core contrib requests requests module"""
22
from __future__ import absolute_import
3+
from urllib.parse import urlparse, parse_qs
4+
35
from werkzeug.datastructures import ImmutableMultiDict
46
from requests import Request
5-
from six.moves.urllib.parse import urlparse, parse_qs
67

78
from openapi_core.validation.request.datatypes import (
89
RequestParameters, OpenAPIRequest,

openapi_core/deserializing/media_types/util.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from email.parser import Parser
22
from json import loads
3-
4-
from six import binary_type
5-
from six.moves.urllib.parse import parse_qsl
3+
from urllib.parse import parse_qsl
64

75

86
def json_loads(value):
97
# python 3.5 doesn't support binary input fix
10-
if isinstance(value, (binary_type, )):
8+
if isinstance(value, (bytes, )):
119
value = value.decode()
1210
return loads(value)
1311

@@ -17,7 +15,7 @@ def urlencoded_form_loads(value):
1715

1816

1917
def data_form_loads(value):
20-
if issubclass(type(value), binary_type):
18+
if issubclass(type(value), bytes):
2119
value = value.decode('ASCII', errors='surrogateescape')
2220
parser = Parser()
2321
parts = parser.parsestr(value, headersonly=False)

openapi_core/schema/schemas.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from __future__ import division
22

3-
from six import iteritems
4-
53

64
def get_all_properties(schema):
75
properties = schema.get('properties', {})
8-
properties_dict = dict(iteritems(properties))
6+
properties_dict = dict(properties.items())
97

108
if 'allOf'not in schema:
119
return properties_dict

openapi_core/schema/servers.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import division
22

3-
from six import iteritems
4-
53

64
def is_absolute(url):
75
return url.startswith('//') or '://' in url
@@ -13,7 +11,7 @@ def get_server_default_variables(server):
1311

1412
defaults = {}
1513
variables = server / 'variables'
16-
for name, variable in iteritems(variables):
14+
for name, variable in variables.items():
1715
defaults[name] = variable['default']
1816
return defaults
1917

openapi_core/templating/paths/finders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""OpenAPI core templating paths finders module"""
22
from __future__ import division
3+
from urllib.parse import urljoin, urlparse
34

45
from more_itertools import peekable
5-
from six.moves.urllib.parse import urljoin, urlparse
66

77
from openapi_core.schema.servers import is_absolute
88
from openapi_core.templating.datatypes import TemplateResult

openapi_core/testing/requests.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""OpenAPI core testing requests module"""
2-
from six.moves.urllib.parse import urljoin
2+
from urllib.parse import urljoin
3+
34
from werkzeug.datastructures import ImmutableMultiDict
45

56
from openapi_core.validation.request.datatypes import (

openapi_core/unmarshalling/schemas/unmarshallers.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
is_object, is_number, is_string,
1010
)
1111
from openapi_schema_validator._format import oas30_format_checker
12-
from six import text_type, binary_type
13-
from six import iteritems
1412

1513
from openapi_core.extensions.models.factories import ModelFactory
1614
from openapi_core.schema.schemas import (
@@ -77,16 +75,16 @@ class StringUnmarshaller(PrimitiveTypeUnmarshaller):
7775

7876
FORMATTERS = {
7977
None: Formatter.from_callables(
80-
partial(is_string, None), text_type),
78+
partial(is_string, None), str),
8179
'password': Formatter.from_callables(
82-
partial(oas30_format_checker.check, format='password'), text_type),
80+
partial(oas30_format_checker.check, format='password'), str),
8381
'date': Formatter.from_callables(
8482
partial(oas30_format_checker.check, format='date'), format_date),
8583
'date-time': Formatter.from_callables(
8684
partial(oas30_format_checker.check, format='date-time'),
8785
parse_datetime),
8886
'binary': Formatter.from_callables(
89-
partial(oas30_format_checker.check, format='binary'), binary_type),
87+
partial(oas30_format_checker.check, format='binary'), bytes),
9088
'uuid': Formatter.from_callables(
9189
partial(oas30_format_checker.check, format='uuid'), format_uuid),
9290
'byte': Formatter.from_callables(
@@ -226,7 +224,7 @@ def _unmarshal_properties(self, value=NoValue, one_of_schema=None):
226224
prop_value = value[prop_name]
227225
properties[prop_name] = prop_value
228226

229-
for prop_name, prop in iteritems(all_props):
227+
for prop_name, prop in all_props.items():
230228
read_only = prop.getkey('readOnly', False)
231229
if self.context == UnmarshalContext.REQUEST and read_only:
232230
continue

openapi_core/unmarshalling/schemas/util.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
from copy import copy
44
import datetime
55
from distutils.util import strtobool
6-
from six import string_types, text_type, integer_types
6+
from functools import lru_cache
77
from uuid import UUID
88

99
from openapi_schema_validator import oas30_format_checker
1010

11-
from openapi_core.compat import lru_cache
12-
1311

1412
def forcebool(val):
15-
if isinstance(val, string_types):
13+
if isinstance(val, str):
1614
val = strtobool(val)
1715

1816
return bool(val)
@@ -29,11 +27,11 @@ def format_uuid(value):
2927

3028

3129
def format_byte(value, encoding='utf8'):
32-
return text_type(b64decode(value), encoding)
30+
return str(b64decode(value), encoding)
3331

3432

3533
def format_number(value):
36-
if isinstance(value, integer_types + (float, )):
34+
if isinstance(value, (int, float)):
3735
return value
3836

3937
return float(value)

requirements.txt

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ isodate==0.6.0
22
dictpath==0.1.3
33
openapi-spec-validator
44
openapi-schema-validator
5-
six
6-
lazy-object-proxy
75
attrs
86
parse==1.14.0
97
more-itertools>=5.0.0

requirements_2.7.txt

-10
This file was deleted.

requirements_dev.txt

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
mock==2.0.0
2-
pytest==3.5.0
1+
pytest==5.4.3
32
pytest-flake8
43
pytest-cov==2.5.1
5-
falcon==2.0.0; python_version<"3.0"
6-
falcon==3.0.0; python_version>="3.0"
4+
falcon==3.0.0
75
flask
8-
django==1.11.29; python_version<"3.0"
9-
django==2.2.18; python_version>="3.0"
6+
django==2.2.18
107
djangorestframework==3.9.4
118
requests==2.22.0
129
responses==0.10.12

setup.cfg

+3-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ classifiers =
99
Intended Audience :: Developers
1010
Topic :: Software Development :: Libraries :: Python Modules
1111
Operating System :: OS Independent
12-
Programming Language :: Python :: 2.7
1312
Programming Language :: Python :: 3.5
1413
Programming Language :: Python :: 3.6
1514
Programming Language :: Python :: 3.7
@@ -22,25 +21,20 @@ include_package_data = True
2221
packages = find:
2322
zip_safe = False
2423
test_suite = tests
25-
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*
24+
python_requires = >= 3.5
2625
setup_requires =
2726
setuptools
2827
install_requires =
2928
isodate
3029
dictpath
3130
openapi-spec-validator
3231
openapi-schema-validator
33-
six
34-
lazy-object-proxy
3532
attrs
3633
werkzeug
3734
parse
3835
more-itertools
39-
backports.functools-lru-cache; python_version<"3.0"
40-
backports.functools-partialmethod; python_version<"3.0"
4136
tests_require =
42-
mock; python_version<"3.0"
43-
pytest
37+
pytest>=5.0.0
4438
pytest-flake8
4539
pytest-cov
4640
falcon
@@ -53,8 +47,7 @@ exclude =
5347
tests
5448

5549
[options.extras_require]
56-
django =
57-
django>=2.2; python_version>="3.0"
50+
django = django>=2.2
5851
flask = flask
5952
requests = requests
6053

tests/integration/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from os import path
2+
from urllib import request
23

34
from openapi_spec_validator.schemas import read_yaml_file
45
import pytest
5-
from six.moves.urllib import request
66
from yaml import safe_load
77

88

tests/integration/contrib/django/conftest.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import mock
2-
import pytest
31
import os
42
import sys
3+
from unittest import mock
4+
5+
import pytest
56

67

7-
@pytest.yield_fixture(autouse=True, scope='module')
8+
@pytest.fixture(autouse=True, scope='module')
89
def django_setup():
910
directory = os.path.abspath(os.path.dirname(__file__))
1011
django_project_dir = os.path.join(directory, 'data')

tests/integration/contrib/django/test_django_rest_framework_apiview.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import pytest
22

3-
from six import b
4-
53

64
class TestDjangoRESTFrameworkAPIView(object):
75

@@ -17,4 +15,4 @@ def test_get(self, api_request_factory):
1715

1816
response = view(request, pk='4')
1917

20-
assert response.content == b('{"test": "test_val"}')
18+
assert response.content == b'{"test": "test_val"}'

tests/integration/contrib/falcon/test_falcon_middlewares.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def middleware(self, spec):
2626
def app(self, middleware):
2727
return App(middleware=[middleware])
2828

29-
@pytest.yield_fixture
29+
@pytest.fixture
3030
def client(self, app):
3131
return TestClient(app)
3232

tests/integration/contrib/flask/test_flask_decorator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def app(self):
2626
app.config['TESTING'] = True
2727
return app
2828

29-
@pytest.yield_fixture
29+
@pytest.fixture
3030
def client(self, app):
3131
with app.test_client() as client:
3232
with app.app_context():

tests/integration/contrib/flask/test_flask_requests.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from six.moves.urllib.parse import urljoin
1+
from urllib.parse import urljoin
2+
23
from werkzeug.datastructures import EnvironHeaders, ImmutableMultiDict
34

45
from openapi_core.contrib.flask import FlaskOpenAPIRequest

tests/integration/contrib/flask/test_flask_views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def app(self):
2121
app.config['TESTING'] = True
2222
return app
2323

24-
@pytest.yield_fixture
24+
@pytest.fixture
2525
def client(self, app):
2626
with app.test_client() as client:
2727
with app.app_context():

0 commit comments

Comments
 (0)