Skip to content

Commit 2b9da55

Browse files
RobbeSneydersp1c2u
authored andcommitted
Drop Python 2.7 and 3.5 support
1 parent eb169e7 commit 2b9da55

File tree

15 files changed

+33
-49
lines changed

15 files changed

+33
-49
lines changed

.github/workflows/python-publish.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,18 @@ 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
2017

21-
- name: Set up Python ${{ matrix.python-version }}
18+
- name: Set up Python
2219
uses: actions/setup-python@v2
2320
with:
24-
python-version: ${{ matrix.python-version }}
21+
python-version: '3.x'
2522

2623
- name: Bootstrap poetry
2724
run: |
28-
python -m pip install --upgrade pip
29-
pip install "poetry<1.2"
25+
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
26+
echo "$HOME/.local/bin" >> $GITHUB_PATH
3027
3128
- name: Build
3229
run: poetry build

.github/workflows/python-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
17+
python-version: [3.6, 3.7, 3.8, 3.9]
1818
os: [windows-latest, ubuntu-latest]
1919
fail-fast: false
2020
steps:

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ language: python
22
sudo: false
33
matrix:
44
include:
5-
- python: 2.7
6-
- python: 3.5
75
- python: 3.6
86
- python: 3.7
97
- python: 3.8

openapi_spec_validator/generators.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""OpenAPI spec validator generators module."""
22
import logging
33

4-
from six import iteritems
54
from jsonschema.validators import Draft4Validator
65

76
from openapi_spec_validator.decorators import DerefValidatorDecorator
@@ -37,6 +36,6 @@ def from_spec_resolver(cls, spec_resolver):
3736
:type instance_resolver: :class:`jsonschema.RefResolver`
3837
"""
3938
deref = DerefValidatorDecorator(spec_resolver)
40-
for key, validator_callable in iteritems(Draft4Validator.VALIDATORS):
39+
for key, validator_callable in Draft4Validator.VALIDATORS.items():
4140
if key in cls.validators:
4241
yield key, deref(validator_callable)

openapi_spec_validator/handlers/file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""OpenAPI spec validator handlers file module."""
2-
from six import StringIO
2+
import io
33
from yaml import load
44

55
from openapi_spec_validator.handlers.base import BaseHandler
@@ -21,7 +21,7 @@ class FileHandler(FileObjectHandler):
2121
"""OpenAPI spec validator file path handler."""
2222

2323
def __call__(self, uri):
24-
if isinstance(uri, StringIO):
24+
if isinstance(uri, io.StringIO):
2525
return super(FileHandler, self).__call__(uri)
2626

2727
assert uri.startswith("file")

openapi_spec_validator/handlers/requests.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""OpenAPI spec validator handlers requests module."""
2-
from __future__ import absolute_import
32
import contextlib
4-
5-
from six import StringIO
6-
from six.moves.urllib.parse import urlparse
3+
import io
74
import requests
5+
import urllib.parse
6+
87

98
from openapi_spec_validator.handlers.file import FileHandler
109

@@ -18,7 +17,7 @@ def __init__(self, *allowed_schemes, **options):
1817
self.allowed_schemes = allowed_schemes
1918

2019
def __call__(self, url):
21-
scheme = urlparse(url).scheme
20+
scheme = urllib.parse.urlparse(url).scheme
2221
assert scheme in self.allowed_schemes
2322

2423
if scheme == "file":
@@ -27,6 +26,6 @@ def __call__(self, url):
2726
response = requests.get(url, timeout=self.timeout)
2827
response.raise_for_status()
2928

30-
data = StringIO(response.text)
29+
data = io.StringIO(response.text)
3130
with contextlib.closing(data) as fh:
3231
return super(UrlRequestsHandler, self).__call__(fh)

openapi_spec_validator/handlers/urllib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""OpenAPI spec validator handlers requests module."""
22
import contextlib
33

4-
from six.moves.urllib.parse import urlparse
5-
from six.moves.urllib.request import urlopen
4+
import urllib.parse
5+
import urllib.request
66

77
from openapi_spec_validator.handlers.file import FileObjectHandler
88

@@ -16,9 +16,9 @@ def __init__(self, *allowed_schemes, **options):
1616
self.allowed_schemes = allowed_schemes
1717

1818
def __call__(self, url):
19-
assert urlparse(url).scheme in self.allowed_schemes
19+
assert urllib.parse.urlparse(url).scheme in self.allowed_schemes
2020

21-
f = urlopen(url, timeout=self.timeout)
21+
f = urllib.request.urlopen(url, timeout=self.timeout)
2222

2323
with contextlib.closing(f) as fh:
2424
return super(UrllibHandler, self).__call__(fh)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os.path
22

3-
from six.moves.urllib.parse import urlparse, unquote
4-
from six.moves.urllib.request import url2pathname
3+
import urllib.parse
4+
import urllib.request
55

66

77
def uri_to_path(uri):
8-
parsed = urlparse(uri)
8+
parsed = urllib.parse.urlparse(uri)
99
host = "{0}{0}{mnt}{0}".format(os.path.sep, mnt=parsed.netloc)
1010
return os.path.normpath(
11-
os.path.join(host, url2pathname(unquote(parsed.path)))
11+
os.path.join(host, urllib.request.url2pathname(urllib.parse.unquote(parsed.path)))
1212
)

openapi_spec_validator/readers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import os
2-
try:
3-
import pathlib
4-
except ImportError:
5-
import pathlib2 as pathlib
2+
import pathlib
63
import sys
74

85
from openapi_spec_validator import all_urls_handler, file_object_handler

openapi_spec_validator/schemas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import os
33

44
from pkg_resources import resource_filename
5-
from six.moves.urllib import parse, request
5+
import urllib.parse
6+
import urllib.request
67
from yaml import load
78

89
from openapi_spec_validator.loaders import ExtendedSafeLoader
@@ -13,7 +14,7 @@ def get_openapi_schema(version):
1314
path_resource = resource_filename('openapi_spec_validator', path)
1415
path_full = os.path.join(os.path.dirname(__file__), path_resource)
1516
schema = read_yaml_file(path_full)
16-
schema_url = parse.urljoin('file:', request.pathname2url(path_full))
17+
schema_url = urllib.parse.urljoin('file:', urllib.request.pathname2url(path_full))
1718
return schema, schema_url
1819

1920

openapi_spec_validator/shortcuts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""OpenAPI spec validator shortcuts module."""
2-
from six.moves.urllib import parse
2+
import urllib.parse
33

44

55
def validate_spec_factory(validator_callable):
@@ -10,7 +10,7 @@ def validate(spec, spec_url=''):
1010

1111
def validate_spec_url_factory(validator_callable, handlers):
1212
def validate(url):
13-
result = parse.urlparse(url)
13+
result = urllib.parse.urlparse(url)
1414
handler = handlers[result.scheme]
1515
spec = handler(url)
1616
return validator_callable(spec, spec_url=url)

openapi_spec_validator/validators.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from jsonschema.validators import RefResolver
55
from openapi_schema_validator import OAS30Validator, oas30_format_checker
6-
from six import iteritems
76

87
from openapi_spec_validator.exceptions import (
98
ParameterDuplicateError, ExtraParametersError, UnresolvableParameterError,
@@ -108,7 +107,7 @@ def __init__(self, dereferencer):
108107
@wraps_errors
109108
def iter_errors(self, schemas):
110109
schemas_deref = self.dereferencer.dereference(schemas)
111-
for name, schema in iteritems(schemas_deref):
110+
for name, schema in schemas_deref.items():
112111
for err in self._iter_schema_errors(schema):
113112
yield err
114113

@@ -164,7 +163,7 @@ def __init__(self, dereferencer, operation_ids_registry=None):
164163
@wraps_errors
165164
def iter_errors(self, paths):
166165
paths_deref = self.dereferencer.dereference(paths)
167-
for url, path_item in iteritems(paths_deref):
166+
for url, path_item in paths_deref.items():
168167
for err in self._iter_path_errors(url, path_item):
169168
yield err
170169

@@ -213,7 +212,7 @@ def iter_errors(self, url, path_item):
213212
for err in self._iter_parameters_errors(parameters):
214213
yield err
215214

216-
for field_name, operation in iteritems(path_item):
215+
for field_name, operation in path_item.items():
217216
if field_name not in self.OPERATIONS:
218217
continue
219218

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ classifiers = [
2323
"Intended Audience :: Developers",
2424
"Topic :: Software Development :: Libraries :: Python Modules",
2525
"Operating System :: OS Independent",
26-
"Programming Language :: Python :: 2.7",
2726
"Programming Language :: Python :: 3",
28-
"Programming Language :: Python :: 3.5",
2927
"Programming Language :: Python :: 3.6",
3028
"Programming Language :: Python :: 3.7",
3129
"Programming Language :: Python :: 3.8",
@@ -38,7 +36,7 @@ jsonschema = ">=3.2.0, <4.0.0"
3836
openapi-schema-validator = "<0.2.0"
3937
pathlib2 = {version = "*", python = "~2.7"}
4038
pyrsistent = "<0.17.0"
41-
python = ">= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*"
39+
python = ">= 3.6"
4240
PyYAML = ">=5.1"
4341
requests = {version = "*", optional = true}
4442
setuptools = "*"
@@ -49,7 +47,6 @@ dev = ["pre-commit"]
4947
requests = ["requests"]
5048

5149
[tool.poetry.dev-dependencies]
52-
mock = {version = "*", python = "~2.7"}
5350
pre-commit = {version = "*", optional = true}
5451
pytest = "=3.5.0"
5552
pytest-flake8 = "=1.0.7"

tests/integration/test_main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
from openapi_spec_validator.__main__ import main
55

6-
try:
7-
from unittest import mock
8-
except ImportError:
9-
import mock
6+
from unittest import mock
107

118

129
def test_schema_default():

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {py27,py35,py36}-{default,simplejson}
2+
envlist = {py36,py37,py38,py39}-{default,simplejson}
33

44
[testenv]
55
deps =

0 commit comments

Comments
 (0)