diff --git a/.travis.yml b/.travis.yml index 375d8bb..8a30d01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,19 +7,14 @@ arch: - ppc64le - arm64 python: - - '2.7' - - '3.4' - - '3.5' - - '3.6' - - '3.7' - '3.8' - '3.9' - '3.10' + - '3.11' - pypy matrix: exclude: - - python: 3.4 - arch: ppc64le python: pypy - arch: arm64 @@ -32,9 +27,10 @@ env: - DEPEENDENCIES="flask==0.10 werkzeug==0.16.1" - DEPEENDENCIES="flask==1.0" - DEPEENDENCIES="flask==1.1" +- DEPEENDENCIES="flask==2.3.2" install: - - pip install -U setuptools pep8 six coverage docutils pygments packaging $DEPEENDENCIES + - pip install -U setuptools pep8 coverage docutils pygments packaging $DEPEENDENCIES script: - coverage erase diff --git a/README.rst b/README.rst index 347a67c..f90ac6c 100644 --- a/README.rst +++ b/README.rst @@ -97,6 +97,9 @@ Tests A simple set of tests is included in ``test/``. To run, install nose, and simply invoke ``nosetests`` or ``python setup.py test`` to exercise the tests. +If nosetests does not work for you, due to it no longer working with newer python versions. +You can use pytest to run the tests instead. + Contributing ------------ diff --git a/flask_cors/__init__.py b/flask_cors/__init__.py index c84a763..458150e 100644 --- a/flask_cors/__init__.py +++ b/flask_cors/__init__.py @@ -24,4 +24,4 @@ rootlogger.addHandler(NullHandler()) if rootlogger.level == logging.NOTSET: - rootlogger.setLevel(logging.WARN) \ No newline at end of file + rootlogger.setLevel(logging.WARN) diff --git a/flask_cors/core.py b/flask_cors/core.py index 6079064..5358036 100644 --- a/flask_cors/core.py +++ b/flask_cors/core.py @@ -9,14 +9,8 @@ """ import re import logging -try: - # on python 3 - from collections.abc import Iterable -except ImportError: - # on python 2.7 and pypy - from collections import Iterable +from collections.abc import Iterable from datetime import timedelta -from six import string_types from flask import request, current_app from werkzeug.datastructures import Headers, MultiDict @@ -82,7 +76,7 @@ def pattern_length(pair): key=pattern_length, reverse=True) - elif isinstance(resources, string_types): + elif isinstance(resources, str): return [(re_fix(resources), {})] elif isinstance(resources, Iterable): @@ -329,9 +323,8 @@ def flexible_str(obj): """ if obj is None: return None - elif(not isinstance(obj, string_types) - and isinstance(obj, Iterable)): - return ', '.join(str(item) for item in sorted(obj)) + elif not isinstance(obj, str) and isinstance(obj, Iterable): + return ", ".join(str(item) for item in sorted(obj)) else: return str(obj) @@ -346,7 +339,7 @@ def ensure_iterable(inst): """ Wraps scalars or string types as a list, or returns the iterable instance. """ - if isinstance(inst, string_types): + if isinstance(inst, str): return [inst] elif not isinstance(inst, Iterable): return [inst] diff --git a/flask_cors/decorator.py b/flask_cors/decorator.py index 2c7a28e..b61d22f 100644 --- a/flask_cors/decorator.py +++ b/flask_cors/decorator.py @@ -9,9 +9,11 @@ :copyright: (c) 2016 by Cory Dolphin. :license: MIT, see LICENSE for more details. """ +import logging from functools import update_wrapper from flask import make_response, request, current_app -from .core import * + +from .core import get_cors_options, set_cors_headers, FLASK_CORS_EVALUATED LOG = logging.getLogger(__name__) diff --git a/flask_cors/extension.py b/flask_cors/extension.py index 7695aad..1d2d938 100644 --- a/flask_cors/extension.py +++ b/flask_cors/extension.py @@ -8,12 +8,19 @@ :copyright: (c) 2016 by Cory Dolphin. :license: MIT, see LICENSE for more details. """ +import logging +from urllib.parse import unquote_plus from flask import request -from .core import * -try: - from urllib.parse import unquote_plus -except ImportError: - from urllib import unquote_plus + +from .core import ( + parse_resources, + get_cors_options, + get_regexp_pattern, + ACL_ORIGIN, + try_match, + set_cors_headers +) + LOG = logging.getLogger(__name__) diff --git a/flask_cors/version.py b/flask_cors/version.py index dd25542..d6497a8 100644 --- a/flask_cors/version.py +++ b/flask_cors/version.py @@ -1 +1 @@ -__version__ = '3.1.01' +__version__ = '4.0.0' diff --git a/requirements.txt b/requirements.txt index 4d6ccbc..af05533 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ Flask>=0.9 -Six diff --git a/setup.py b/setup.py index 91a26d6..b10bd39 100644 --- a/setup.py +++ b/setup.py @@ -43,16 +43,10 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',