Skip to content

Commit

Permalink
Drop Python 3.6 support (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Jan 23, 2022
1 parent 7a7f239 commit 2830a3d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 61 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
- ?.?* # matches to backport branches, e.g. 3.6
- ?.?* # matches to backport branches, e.g. 3.9
tags: [ 'v*' ]
pull_request:
branches:
Expand Down Expand Up @@ -65,10 +65,9 @@ jobs:
test:
name: Test
needs: lint
strategy:
matrix:
pyver: ['3.6', '3.7', '3.8', '3.9', '3.10']
pyver: ['3.7', '3.8', '3.9', '3.10']
no-extensions: ['', 'Y']
os: [ubuntu, macos, windows]
exclude:
Expand All @@ -77,7 +76,7 @@ jobs:
- os: windows
no-extensions: 'Y'
include:
- pyver: pypy3
- pyver: pypy-3.8
no-extensions: 'Y'
os: ubuntu
fail-fast: false
Expand Down Expand Up @@ -131,10 +130,21 @@ jobs:
flags: unit
fail_ci_if_error: false

test-summary:
name: Tests status
if: always()
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

pre-deploy:
name: Pre-Deploy
runs-on: ubuntu-latest
needs: test
needs: test-summary
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGES/672.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped Python 3.6 support.
7 changes: 1 addition & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

from setuptools import Extension, setup

if sys.version_info < (3, 5):
raise RuntimeError("yarl 1.4+ requires Python 3.5+")


NO_EXTENSIONS = bool(os.environ.get("YARL_NO_EXTENSIONS")) # type: bool

if sys.implementation.name != "cpython":
Expand Down Expand Up @@ -53,7 +49,6 @@ def read(name):
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -66,7 +61,7 @@ def read(name):
license="Apache 2",
packages=["yarl"],
install_requires=install_requires,
python_requires=">=3.6",
python_requires=">=3.7",
include_package_data=True,
exclude_package_data={"": ["*.c"]},
)
Expand Down
71 changes: 21 additions & 50 deletions yarl/_url.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import math
import sys
import warnings
from collections.abc import Mapping, Sequence
from ipaddress import ip_address
Expand Down Expand Up @@ -706,55 +705,27 @@ def _normalize_path(cls, path):

return "/".join(resolved_path)

if sys.version_info >= (3, 7):

@classmethod
def _encode_host(cls, host, human=False):
try:
ip, sep, zone = host.partition("%")
ip = ip_address(ip)
except ValueError:
host = host.lower()
# IDNA encoding is slow,
# skip it for ASCII-only strings
# Don't move the check into _idna_encode() helper
# to reduce the cache size
if human or host.isascii():
return host
host = _idna_encode(host)
else:
host = ip.compressed
if sep:
host += "%" + zone
if ip.version == 6:
host = "[" + host + "]"
return host

else:
# work around for missing str.isascii() in Python <= 3.6
@classmethod
def _encode_host(cls, host, human=False):
try:
ip, sep, zone = host.partition("%")
ip = ip_address(ip)
except ValueError:
host = host.lower()
if human:
return host

for char in host:
if char > "\x7f":
break
else:
return host
host = _idna_encode(host)
else:
host = ip.compressed
if sep:
host += "%" + zone
if ip.version == 6:
host = "[" + host + "]"
return host
@classmethod
def _encode_host(cls, host, human=False):
try:
ip, sep, zone = host.partition("%")
ip = ip_address(ip)
except ValueError:
host = host.lower()
# IDNA encoding is slow,
# skip it for ASCII-only strings
# Don't move the check into _idna_encode() helper
# to reduce the cache size
if human or host.isascii():
return host
host = _idna_encode(host)
else:
host = ip.compressed
if sep:
host += "%" + zone
if ip.version == 6:
host = "[" + host + "]"
return host

@classmethod
def _make_netloc(
Expand Down

0 comments on commit 2830a3d

Please sign in to comment.