Skip to content

Commit

Permalink
chore: remove python 3.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Aug 15, 2024
1 parent 8edba8c commit faad3e3
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 107 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/create-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
- "windows-latest"
- "macos-latest"
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand Down Expand Up @@ -95,7 +93,6 @@ jobs:
- "ubuntu-latest"
python-version:
# the versions are <python tag>-<abi tag> as specified in PEP 425.
- cp37-cp37m
- cp38-cp38
- cp39-cp39
- cp310-cp310
Expand Down Expand Up @@ -227,7 +224,6 @@ jobs:
- "ubuntu-latest"
python-version:
# the versions are <python tag>-<abi tag> as specified in PEP 425.
- cp37-cp37m
- cp38-cp38
- cp39-cp39
- cp310-cp310
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
- python-version: pypy3.9
os: ubuntu-latest
toxenv: pypy3
- python-version: "3.7"
os: ubuntu-latest
toxenv: py37
- python-version: "3.8"
os: ubuntu-latest
toxenv: py38
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ clean design that embraces HTTP and the REST architectural style.

Falcon apps work with any `WSGI <https://www.python.org/dev/peps/pep-3333/>`_
or `ASGI <https://asgi.readthedocs.io/en/latest/>`_ server, and run like a
champ under CPython 3.7+ and PyPy 3.7+.
champ under CPython 3.8+ and PyPy 3.8+.

Quick Links
-----------
Expand Down
4 changes: 2 additions & 2 deletions falcon/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
PYTHON_VERSION = tuple(sys.version_info[:3])
"""Python version information triplet: (major, minor, micro)."""

FALCON_SUPPORTED = PYTHON_VERSION >= (3, 7, 0)
FALCON_SUPPORTED = PYTHON_VERSION >= (3, 8, 0)
"""Whether this version of Falcon supports the current Python version."""

if not FALCON_SUPPORTED: # pragma: nocover
raise ImportError(
'Falcon requires Python 3.7+. '
'Falcon requires Python 3.8+. '
'(Recent Pip should automatically pick a suitable Falcon version.)'
)

Expand Down
27 changes: 0 additions & 27 deletions falcon/cyutil/misc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,6 @@
# limitations under the License.


def isascii(unicode string not None):
"""Return ``True`` if all characters in the string are ASCII.
ASCII characters have code points in the range U+0000-U+007F.
Note:
On Python 3.7+, this function is just aliased to ``str.isascii``.
This is a Cython fallback for older CPython versions. For longer strings,
it is slightly less performant than the built-in ``str.isascii``.
Args:
string (str): A string to test.
Returns:
``True`` if all characters are ASCII, ``False`` otherwise.
"""

cdef Py_UCS4 ch

for ch in string:
if ch > 0x007F:
return False

return True


def encode_items_to_latin1(dict data not None):
cdef list result = []
cdef unicode key
Expand Down
3 changes: 1 addition & 2 deletions falcon/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from falcon.media.json import _DEFAULT_JSON_HANDLER
from falcon.stream import BoundedStream
from falcon.util import structures
from falcon.util.misc import isascii
from falcon.util.uri import parse_host
from falcon.util.uri import parse_query_string
from falcon.vendor import mimeparse
Expand Down Expand Up @@ -489,7 +488,7 @@ def __init__(self, env, options=None):

# perf(vytas): Only decode the tunnelled path in case it is not ASCII.
# For ASCII-strings, the below decoding chain is a no-op.
if not isascii(path):
if not path.isascii():
path = path.encode('iso-8859-1').decode('utf-8', 'replace')

if (
Expand Down
3 changes: 1 addition & 2 deletions falcon/response_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Utilities for the Response class."""

from falcon.util import uri
from falcon.util.misc import isascii
from falcon.util.misc import secure_filename


Expand Down Expand Up @@ -91,7 +90,7 @@ def format_content_disposition(value, disposition_type='attachment'):
# NOTE(vytas): RFC 6266, Appendix D.
# Include a "filename" parameter when US-ASCII ([US-ASCII]) is
# sufficiently expressive.
if isascii(value):
if value.isascii():
return '%s; filename="%s"' % (disposition_type, value)

# NOTE(vytas): RFC 6266, Appendix D.
Expand Down
36 changes: 4 additions & 32 deletions falcon/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
except ImportError:
_cy_encode_items_to_latin1 = None

try:
from falcon.cyutil.misc import isascii as _cy_isascii
except ImportError:
_cy_isascii = None


__all__ = (
'is_python_func',
'deprecated',
Expand Down Expand Up @@ -506,30 +500,8 @@ def _encode_items_to_latin1(data: Dict[str, str]) -> List[Tuple[bytes, bytes]]:
return result


def _isascii(string: str) -> bool:
"""Return ``True`` if all characters in the string are ASCII.
ASCII characters have code points in the range U+0000-U+007F.
Note:
On Python 3.7+, this function is just aliased to ``str.isascii``.
This is a pure-Python fallback for older CPython (where Cython is
unavailable) and PyPy versions.
Args:
string (str): A string to test.
Returns:
``True`` if all characters are ASCII, ``False`` otherwise.
"""

try:
string.encode('ascii')
return True
except ValueError:
return False


_encode_items_to_latin1 = _cy_encode_items_to_latin1 or _encode_items_to_latin1
isascii = getattr(str, 'isascii', _cy_isascii or _isascii)

isascii = deprecated('This will be removed in V5. Please use `str.isascii`')(
str.isascii
)
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
[tool.black]
# this is kept to avoid reformatting all the code if one were to
# inadvertently run black on the project
target-version = ["py37"]
target-version = ["py38"]
skip-string-normalization = true
line-length = 88
extend-exclude = "falcon/vendor"
Expand All @@ -100,12 +100,12 @@
# NOTE(vytas): Before switching to Ruff, Falcon used the Blue formatter.
# With the below settings, accidentally running blue should yield
# only minor cosmetic changes in a handful of files.
target-version = ["py37"]
target-version = ["py38"]
line-length = 88
extend-exclude = "falcon/vendor"

[tool.ruff]
target-version = "py37"
target-version = "py38"
format.quote-style = "single"
line-length = 88
extend-exclude = ["falcon/vendor"]
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ classifiers =
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand Down Expand Up @@ -53,7 +52,7 @@ project_urls =
zip_safe = False
include_package_data = True
packages = find:
python_requires = >=3.7
python_requires = >=3.8
install_requires =
tests_require =
testtools
Expand Down
25 changes: 3 additions & 22 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,25 +645,9 @@ def test_secure_filename_empty_value(self):
with pytest.raises(ValueError):
misc.secure_filename('')

@pytest.mark.parametrize(
'string,expected_ascii',
[
('', True),
('/', True),
('/api', True),
('/data/items/something?query=apples%20and%20oranges', True),
('/food?item=ð\x9f\x8d\x94', False),
('\x00\x00\x7f\x00\x00\x7f\x00', True),
('\x00\x00\x7f\x00\x00\x80\x00', False),
],
)
@pytest.mark.parametrize('method', ['isascii', '_isascii'])
def test_misc_isascii(self, string, expected_ascii, method):
isascii = getattr(misc, method)
if expected_ascii:
assert isascii(string)
else:
assert not isascii(string)
def test_misc_isascii(self):
with pytest.warns(DeprecationWarning):
assert misc.isascii('foobar')


@pytest.mark.parametrize(
Expand Down Expand Up @@ -1427,9 +1411,6 @@ def a_function(a=1, b=2):
assert 'a_function(...)' in str(recwarn[0].message)


@pytest.mark.skipif(
falcon.PYTHON_VERSION < (3, 7), reason='module __getattr__ requires python 3.7'
)
def test_json_deprecation():
with pytest.warns(deprecation.DeprecatedWarning, match='json'):
util.json
Expand Down
8 changes: 1 addition & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ setenv =
PYTHONASYNCIODEBUG=1
commands = pytest tests []

[testenv:py37_cython]
basepython = python3.7
deps = {[with-cython]deps}
setenv = {[with-cython]setenv}
commands = {[with-cython]commands}

[testenv:py38_cython]
basepython = python3.8
deps = {[with-cython]deps}
Expand Down Expand Up @@ -471,7 +465,7 @@ commands =
# --------------------------------------------------------------------

[testenv:hug]
basepython = python3.7
basepython = python3.8
deps = virtualenv
commands =
{toxinidir}/tools/testing/install_hug.sh
Expand Down

0 comments on commit faad3e3

Please sign in to comment.