Skip to content

Python2 support drop #335

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

Merged
merged 1 commit into from
May 21, 2021
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
7 changes: 2 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.6]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: python
sudo: false
matrix:
include:
- python: 2.7
- python: 3.5
- python: 3.6
- python: 3.7
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ include LICENSE
include README.rst
include requirements.txt
include requirements_dev.txt
include requirements_2.7.txt
3 changes: 1 addition & 2 deletions openapi_core/casting/schemas/util.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""OpenAPI core casting schemas util module"""
from distutils.util import strtobool
from six import string_types


def forcebool(val):
if isinstance(val, string_types):
if isinstance(val, str):
val = strtobool(val)

return bool(val)
12 changes: 0 additions & 12 deletions openapi_core/compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion openapi_core/contrib/django/requests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""OpenAPI core contrib django requests module"""
import re

from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin

from openapi_core.contrib.django.compat import (
get_request_headers, get_current_scheme_host,
Expand Down
2 changes: 1 addition & 1 deletion openapi_core/contrib/flask/requests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""OpenAPI core contrib flask requests module"""
import re

from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin

from openapi_core.validation.request.datatypes import (
RequestParameters, OpenAPIRequest,
Expand Down
3 changes: 2 additions & 1 deletion openapi_core/contrib/requests/requests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""OpenAPI core contrib requests requests module"""
from __future__ import absolute_import
from urllib.parse import urlparse, parse_qs

from werkzeug.datastructures import ImmutableMultiDict
from requests import Request
from six.moves.urllib.parse import urlparse, parse_qs

from openapi_core.validation.request.datatypes import (
RequestParameters, OpenAPIRequest,
Expand Down
8 changes: 3 additions & 5 deletions openapi_core/deserializing/media_types/util.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from email.parser import Parser
from json import loads

from six import binary_type
from six.moves.urllib.parse import parse_qsl
from urllib.parse import parse_qsl


def json_loads(value):
# python 3.5 doesn't support binary input fix
if isinstance(value, (binary_type, )):
if isinstance(value, (bytes, )):
value = value.decode()
return loads(value)

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


def data_form_loads(value):
if issubclass(type(value), binary_type):
if issubclass(type(value), bytes):
value = value.decode('ASCII', errors='surrogateescape')
parser = Parser()
parts = parser.parsestr(value, headersonly=False)
Expand Down
4 changes: 1 addition & 3 deletions openapi_core/schema/schemas.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from __future__ import division

from six import iteritems


def get_all_properties(schema):
properties = schema.get('properties', {})
properties_dict = dict(iteritems(properties))
properties_dict = dict(properties.items())

if 'allOf'not in schema:
return properties_dict
Expand Down
4 changes: 1 addition & 3 deletions openapi_core/schema/servers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import division

from six import iteritems


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

defaults = {}
variables = server / 'variables'
for name, variable in iteritems(variables):
for name, variable in variables.items():
defaults[name] = variable['default']
return defaults

Expand Down
2 changes: 1 addition & 1 deletion openapi_core/templating/paths/finders.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""OpenAPI core templating paths finders module"""
from __future__ import division
from urllib.parse import urljoin, urlparse

from more_itertools import peekable
from six.moves.urllib.parse import urljoin, urlparse

from openapi_core.schema.servers import is_absolute
from openapi_core.templating.datatypes import TemplateResult
Expand Down
3 changes: 2 additions & 1 deletion openapi_core/testing/requests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""OpenAPI core testing requests module"""
from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin

from werkzeug.datastructures import ImmutableMultiDict

from openapi_core.validation.request.datatypes import (
Expand Down
10 changes: 4 additions & 6 deletions openapi_core/unmarshalling/schemas/unmarshallers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
is_object, is_number, is_string,
)
from openapi_schema_validator._format import oas30_format_checker
from six import text_type, binary_type
from six import iteritems

from openapi_core.extensions.models.factories import ModelFactory
from openapi_core.schema.schemas import (
Expand Down Expand Up @@ -77,16 +75,16 @@ class StringUnmarshaller(PrimitiveTypeUnmarshaller):

FORMATTERS = {
None: Formatter.from_callables(
partial(is_string, None), text_type),
partial(is_string, None), str),
'password': Formatter.from_callables(
partial(oas30_format_checker.check, format='password'), text_type),
partial(oas30_format_checker.check, format='password'), str),
'date': Formatter.from_callables(
partial(oas30_format_checker.check, format='date'), format_date),
'date-time': Formatter.from_callables(
partial(oas30_format_checker.check, format='date-time'),
parse_datetime),
'binary': Formatter.from_callables(
partial(oas30_format_checker.check, format='binary'), binary_type),
partial(oas30_format_checker.check, format='binary'), bytes),
'uuid': Formatter.from_callables(
partial(oas30_format_checker.check, format='uuid'), format_uuid),
'byte': Formatter.from_callables(
Expand Down Expand Up @@ -226,7 +224,7 @@ def _unmarshal_properties(self, value=NoValue, one_of_schema=None):
prop_value = value[prop_name]
properties[prop_name] = prop_value

for prop_name, prop in iteritems(all_props):
for prop_name, prop in all_props.items():
read_only = prop.getkey('readOnly', False)
if self.context == UnmarshalContext.REQUEST and read_only:
continue
Expand Down
10 changes: 4 additions & 6 deletions openapi_core/unmarshalling/schemas/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
from copy import copy
import datetime
from distutils.util import strtobool
from six import string_types, text_type, integer_types
from functools import lru_cache
from uuid import UUID

from openapi_schema_validator import oas30_format_checker

from openapi_core.compat import lru_cache


def forcebool(val):
if isinstance(val, string_types):
if isinstance(val, str):
val = strtobool(val)

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


def format_byte(value, encoding='utf8'):
return text_type(b64decode(value), encoding)
return str(b64decode(value), encoding)


def format_number(value):
if isinstance(value, integer_types + (float, )):
if isinstance(value, (int, float)):
return value

return float(value)
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ isodate==0.6.0
dictpath==0.1.3
openapi-spec-validator
openapi-schema-validator
six
lazy-object-proxy
attrs
parse==1.14.0
more-itertools>=5.0.0
10 changes: 0 additions & 10 deletions requirements_2.7.txt

This file was deleted.

9 changes: 3 additions & 6 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
mock==2.0.0
pytest==3.5.0
pytest==5.4.3
pytest-flake8
pytest-cov==2.5.1
falcon==2.0.0; python_version<"3.0"
falcon==3.0.0; python_version>="3.0"
falcon==3.0.0
flask
django==1.11.29; python_version<"3.0"
django==2.2.18; python_version>="3.0"
django==2.2.18
djangorestframework==3.9.4
requests==2.22.0
responses==0.10.12
Expand Down
13 changes: 3 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ classifiers =
Intended Audience :: Developers
Topic :: Software Development :: Libraries :: Python Modules
Operating System :: OS Independent
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Expand All @@ -22,25 +21,20 @@ include_package_data = True
packages = find:
zip_safe = False
test_suite = tests
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*
python_requires = >= 3.5
setup_requires =
setuptools
install_requires =
isodate
dictpath
openapi-spec-validator
openapi-schema-validator
six
lazy-object-proxy
attrs
werkzeug
parse
more-itertools
backports.functools-lru-cache; python_version<"3.0"
backports.functools-partialmethod; python_version<"3.0"
tests_require =
mock; python_version<"3.0"
pytest
pytest>=5.0.0
pytest-flake8
pytest-cov
falcon
Expand All @@ -53,8 +47,7 @@ exclude =
tests

[options.extras_require]
django =
django>=2.2; python_version>="3.0"
django = django>=2.2
flask = flask
requests = requests

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from os import path
from urllib import request

from openapi_spec_validator.schemas import read_yaml_file
import pytest
from six.moves.urllib import request
from yaml import safe_load


Expand Down
7 changes: 4 additions & 3 deletions tests/integration/contrib/django/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import mock
import pytest
import os
import sys
from unittest import mock

import pytest


@pytest.yield_fixture(autouse=True, scope='module')
@pytest.fixture(autouse=True, scope='module')
def django_setup():
directory = os.path.abspath(os.path.dirname(__file__))
django_project_dir = os.path.join(directory, 'data')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import pytest

from six import b


class TestDjangoRESTFrameworkAPIView(object):

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

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

assert response.content == b('{"test": "test_val"}')
assert response.content == b'{"test": "test_val"}'
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def middleware(self, spec):
def app(self, middleware):
return App(middleware=[middleware])

@pytest.yield_fixture
@pytest.fixture
def client(self, app):
return TestClient(app)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/contrib/flask/test_flask_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def app(self):
app.config['TESTING'] = True
return app

@pytest.yield_fixture
@pytest.fixture
def client(self, app):
with app.test_client() as client:
with app.app_context():
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/contrib/flask/test_flask_requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin

from werkzeug.datastructures import EnvironHeaders, ImmutableMultiDict

from openapi_core.contrib.flask import FlaskOpenAPIRequest
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/contrib/flask/test_flask_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def app(self):
app.config['TESTING'] = True
return app

@pytest.yield_fixture
@pytest.fixture
def client(self, app):
with app.test_client() as client:
with app.app_context():
Expand Down
Loading