Skip to content

Commit

Permalink
Drop support for EOL Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Feb 4, 2022
1 parent a507200 commit 0d710ce
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['pypy-3.6', 'pypy-3.7', '3.6', '3.7', '3.8', '3.9', '3.10-dev']
python-version: ['pypy-3.7', '3.7', '3.8', '3.9', '3.10', '3.11-dev']
os: [ubuntu-latest, macos-latest, windows-latest]
continue-on-error: ${{ matrix.python-version == '3.10-dev' }}
continue-on-error: ${{ matrix.python-version == '3.11-dev' }}

steps:
- uses: actions/checkout@v2
Expand All @@ -54,7 +54,7 @@ jobs:
pytest --cov --cov-fail-under=75
- name: Report coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.6'
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v1

allgood:
Expand Down
14 changes: 3 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ authors = [
{ name = "Taneli Hukkinen", email = "hukkin@users.noreply.github.com" },
]
license = { file = "LICENSE" }
requires-python = ">=3.6"
requires-python = ">=3.7"
readme = "README.md"
classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -34,13 +33,6 @@ keywords = ["markdown", "commonmark"]
"Homepage" = "https://github.com/executablebooks/mdurl"


[tool.flit.sdist]
exclude = [
"tests/",
".*",
]


[tool.isort]
# Force imports to be sorted by module, independent of import type
force_sort_within_sections = true
Expand All @@ -63,10 +55,10 @@ xfail_strict = true
legacy_tox_ini = '''
[tox]
# Only run pytest envs when no args given to tox
envlist = py{36,37,38,39}
envlist = py{37,38,39,310}
isolated_build = True
[testenv:py{36,37,38,39}]
[testenv:py{37,38,39,310}]
description = run tests
deps = -r tests/requirements.txt
commands =
Expand Down
8 changes: 5 additions & 3 deletions src/mdurl/_decode.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from __future__ import annotations

from collections.abc import Sequence
import functools
import re
from typing import Dict, List, Sequence

DECODE_DEFAULT_CHARS = ";/?:@&=+$,#"
DECODE_COMPONENT_CHARS = ""

decode_cache: Dict[str, List[str]] = {}
decode_cache: dict[str, list[str]] = {}


def get_decode_cache(exclude: str) -> Sequence[str]:
if exclude in decode_cache:
return decode_cache[exclude]

cache: List[str] = []
cache: list[str] = []
decode_cache[exclude] = cache

for i in range(128):
Expand Down
8 changes: 5 additions & 3 deletions src/mdurl/_encode.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

from collections.abc import Sequence
from string import ascii_letters, digits, hexdigits
from typing import Dict, List, Sequence
from urllib.parse import quote as encode_uri_component

ASCII_LETTERS_AND_DIGITS = ascii_letters + digits

ENCODE_DEFAULT_CHARS = ";/?:@&=+$,-_.!~*'()#"
ENCODE_COMPONENT_CHARS = "-_.!~*'()"

encode_cache: Dict[str, List[str]] = {}
encode_cache: dict[str, list[str]] = {}


# Create a lookup array where anything but characters in `chars` string
Expand All @@ -16,7 +18,7 @@ def get_encode_cache(exclude: str) -> Sequence[str]:
if exclude in encode_cache:
return encode_cache[exclude]

cache: List[str] = []
cache: list[str] = []
encode_cache[exclude] = cache

for i in range(128):
Expand Down
4 changes: 3 additions & 1 deletion src/mdurl/_format.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from mdurl._url import URL


def format(url: "URL") -> str: # noqa: A001
def format(url: URL) -> str: # noqa: A001
result = ""

result += url.protocol or ""
Expand Down
19 changes: 10 additions & 9 deletions src/mdurl/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
# 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
# which can be constructed using other parts of the url.

from __future__ import annotations

from collections import defaultdict
import re
from typing import Optional, Union

from mdurl._url import URL

Expand Down Expand Up @@ -103,14 +104,14 @@

class MutableURL:
def __init__(self) -> None:
self.protocol: Optional[str] = None
self.protocol: str | None = None
self.slashes: bool = False
self.auth: Optional[str] = None
self.port: Optional[str] = None
self.hostname: Optional[str] = None
self.hash: Optional[str] = None
self.search: Optional[str] = None
self.pathname: Optional[str] = None
self.auth: str | None = None
self.port: str | None = None
self.hostname: str | None = None
self.hash: str | None = None
self.search: str | None = None
self.pathname: str | None = None

def parse(self, url: str, slashes_denote_host: bool) -> "MutableURL":
lower_proto = ""
Expand Down Expand Up @@ -293,7 +294,7 @@ def parse_host(self, host: str) -> None:
self.hostname = host


def url_parse(url: Union[URL, str], *, slashes_denote_host: bool = False) -> URL:
def url_parse(url: URL | str, *, slashes_denote_host: bool = False) -> URL:
if isinstance(url, URL):
return url
u = MutableURL()
Expand Down
18 changes: 10 additions & 8 deletions src/mdurl/_url.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from typing import NamedTuple, Optional
from __future__ import annotations

from typing import NamedTuple


class URL(NamedTuple):
protocol: Optional[str]
protocol: str | None
slashes: bool
auth: Optional[str]
port: Optional[str]
hostname: Optional[str]
hash: Optional[str] # noqa: A003
search: Optional[str]
pathname: Optional[str]
auth: str | None
port: str | None
hostname: str | None
hash: str | None # noqa: A003
search: str | None
pathname: str | None

0 comments on commit 0d710ce

Please sign in to comment.