diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1386995..f956d2a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: trailing-whitespace exclude: ^tests/.+\.html @@ -10,18 +10,18 @@ repos: - id: check-added-large-files - id: check-toml - - repo: https://github.com/psf/black - rev: 23.11.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.3.1 hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 8.0.1 hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.3.0 hooks: - id: flake8 additional_dependencies: @@ -34,6 +34,6 @@ repos: - pep8-naming - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.0 + rev: v1.20.1 hooks: - id: mypy diff --git a/src/urlstd/parse.py b/src/urlstd/parse.py index f15a6df..f5b0ed5 100644 --- a/src/urlstd/parse.py +++ b/src/urlstd/parse.py @@ -1911,28 +1911,24 @@ class URLSearchParams(Collection): """ @overload - def __init__(self, init: str) -> None: - ... + def __init__(self, init: str) -> None: ... @overload - def __init__(self, init: Sequence[Sequence[str | int | float]]) -> None: - ... + def __init__( + self, init: Sequence[Sequence[str | int | float]] + ) -> None: ... @overload - def __init__(self, init: dict[str, str | int | float]) -> None: - ... + def __init__(self, init: dict[str, str | int | float]) -> None: ... @overload - def __init__(self, init: URLRecord) -> None: - ... + def __init__(self, init: URLRecord) -> None: ... @overload - def __init__(self, init: "URLSearchParams") -> None: - ... + def __init__(self, init: "URLSearchParams") -> None: ... @overload - def __init__(self) -> None: - ... + def __init__(self) -> None: ... def __init__( self, diff --git a/tests/test_api.py b/tests/test_api.py index de2e03b..43acb50 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1409,7 +1409,7 @@ def test_idna_domain_to_ascii_raise_icuerror(caplog, mocker): def test_idna_domain_to_ascii_use_std3_rules(caplog): """Unicode ToASCII: UseSTD3ASCIIRules=true: A domain contains non-LDH ASCII.""" caplog.set_level(logging.INFO) - domain = "a\u2260b\u226Ec\u226Fd" + domain = "a\u2260b\u226ec\u226fd" assert IDNA.domain_to_ascii(domain) == "xn--abcd-5n9aqdi" assert len(caplog.record_tuples) == 0 @@ -1595,7 +1595,7 @@ def test_idna_domain_to_unicode_use_std3_rules(caplog): caplog.set_level(logging.INFO) ascii_domain = "xn--abcd-5n9aqdi" - domain = "a\u2260b\u226Ec\u226Fd" + domain = "a\u2260b\u226ec\u226fd" assert IDNA.domain_to_unicode(ascii_domain) == domain assert len(caplog.record_tuples) == 0 @@ -3553,15 +3553,15 @@ def test_urlsearchparams_construct_raise_exception(): def test_urlsearchparams_construct_with_surrogates(): """URLSearchParams construct with 3 unpaired surrogates (no leading)""" params = URLSearchParams( - [["x\uDC53", "1"], ["x\uDC53", 2], ["x\uDC53", 3.0]] + [["x\udc53", "1"], ["x\udc53", 2], ["x\udc53", 3.0]] ) assert len(params) == 3 - assert params.get("x\uDC53") == "1" - assert params.get("x\uFFFD") == "1" - assert params.get_all("x\uDC53") == ("1", "2", "3.0") - assert params.get_all("x\uFFFD") == ("1", "2", "3.0") + assert params.get("x\udc53") == "1" + assert params.get("x\ufffd") == "1" + assert params.get_all("x\udc53") == ("1", "2", "3.0") + assert params.get_all("x\ufffd") == ("1", "2", "3.0") - params.delete("x\uFFFD") + params.delete("x\ufffd") assert len(params) == 0 diff --git a/tests/wpt/test_urlencoded_parser.py b/tests/wpt/test_urlencoded_parser.py index c95ef35..d3f6fd7 100644 --- a/tests/wpt/test_urlencoded_parser.py +++ b/tests/wpt/test_urlencoded_parser.py @@ -10,20 +10,20 @@ "val", [ {"input": "test", "output": [["test", ""]]}, - {"input": "\uFEFFtest=\uFEFF", "output": [["\uFEFFtest", "\uFEFF"]]}, + {"input": "\ufefftest=\ufeff", "output": [["\ufefftest", "\ufeff"]]}, { "input": "%EF%BB%BFtest=%EF%BB%BF", - "output": [["\uFEFFtest", "\uFEFF"]], + "output": [["\ufefftest", "\ufeff"]], }, - {"input": "%EF%BF%BF=%EF%BF%BF", "output": [["\uFFFF", "\uFFFF"]]}, - {"input": "%FE%FF", "output": [["\uFFFD\uFFFD", ""]]}, - {"input": "%FF%FE", "output": [["\uFFFD\uFFFD", ""]]}, + {"input": "%EF%BF%BF=%EF%BF%BF", "output": [["\uffff", "\uffff"]]}, + {"input": "%FE%FF", "output": [["\ufffd\ufffd", ""]]}, + {"input": "%FF%FE", "output": [["\ufffd\ufffd", ""]]}, {"input": "†&†=x", "output": [["†", ""], ["†", "x"]]}, - {"input": "%C2", "output": [["\uFFFD", ""]]}, - {"input": "%C2x", "output": [["\uFFFDx", ""]]}, + {"input": "%C2", "output": [["\ufffd", ""]]}, + {"input": "%C2x", "output": [["\ufffdx", ""]]}, { "input": "_charset_=windows-1252&test=%C2x", - "output": [["_charset_", "windows-1252"], ["test", "\uFFFDx"]], + "output": [["_charset_", "windows-1252"], ["test", "\ufffdx"]], }, {"input": "", "output": []}, {"input": "a", "output": [["a", ""]]}, diff --git a/tests/wpt/test_urlsearchparams_constructor.py b/tests/wpt/test_urlsearchparams_constructor.py index a252632..21c8f6a 100644 --- a/tests/wpt/test_urlsearchparams_constructor.py +++ b/tests/wpt/test_urlsearchparams_constructor.py @@ -163,12 +163,12 @@ def test_parse_percent_encoded_2384(): def test_parse_d83d_dca9(): """Parse \\uD83D\\uDCA9""" - params = URLSearchParams("a=b\uD83D\uDCA9c") + params = URLSearchParams("a=b\ud83d\udca9c") # assert params.get("a") == "b\uD83D\uDCA9c", list(params) # NOTE: "b\uD83D\uDCA9c" and "b\U0001F4A9c" are not equal in Python. - assert params.get("a") == "b\U0001F4A9c", list(params) - params = URLSearchParams("a\uD83D\uDCA9b=c") - assert params.get("a\uD83D\uDCA9b") == "c", list(params) + assert params.get("a") == "b\U0001f4a9c", list(params) + params = URLSearchParams("a\ud83d\udca9b=c") + assert params.get("a\ud83d\udca9b") == "c", list(params) def test_parse_percent_encoded_d83d_dca9(): @@ -176,9 +176,9 @@ def test_parse_percent_encoded_d83d_dca9(): params = URLSearchParams("a=b%f0%9f%92%a9c") # assert params.get("a") == "b\uD83D\uDCA9c", list(params) # NOTE: "b\uD83D\uDCA9c" and "b\U0001F4A9c" are not equal in Python. - assert params.get("a") == "b\U0001F4A9c", list(params) + assert params.get("a") == "b\U0001f4a9c", list(params) params = URLSearchParams("a%f0%9f%92%a9b=c") - assert params.get("a\uD83D\uDCA9b") == "c", list(params) + assert params.get("a\ud83d\udca9b") == "c", list(params) def test_sequences_of_strings(): @@ -211,18 +211,18 @@ def test_sequences_of_strings(): "name": "array with two keys", }, { - "input": {"\uD835x": "1", "xx": "2", "\uD83Dx": "3"}, - "output": [["\uFFFDx", "3"], ["xx", "2"]], + "input": {"\ud835x": "1", "xx": "2", "\ud83dx": "3"}, + "output": [["\ufffdx", "3"], ["xx", "2"]], "name": "2 unpaired surrogates (no trailing)", }, { - "input": {"x\uDC53": "1", "x\uDC5C": "2", "x\uDC65": "3"}, - "output": [["x\uFFFD", "3"]], + "input": {"x\udc53": "1", "x\udc5c": "2", "x\udc65": "3"}, + "output": [["x\ufffd", "3"]], "name": "3 unpaired surrogates (no leading)", }, { - "input": {"a\0b": "42", "c\uD83D": "23", "d\u1234": "foo"}, - "output": [["a\0b", "42"], ["c\uFFFD", "23"], ["d\u1234", "foo"]], + "input": {"a\0b": "42", "c\ud83d": "23", "d\u1234": "foo"}, + "output": [["a\0b", "42"], ["c\ufffd", "23"], ["d\u1234", "foo"]], "name": "object with NULL, non-ASCII, and surrogate keys", }, ], diff --git a/tests/wpt/test_urlsearchparams_sort.py b/tests/wpt/test_urlsearchparams_sort.py index 4070f8b..b7a61f5 100644 --- a/tests/wpt/test_urlsearchparams_sort.py +++ b/tests/wpt/test_urlsearchparams_sort.py @@ -11,8 +11,8 @@ "output": [["a", "b"], ["a", "a"], ["z", "b"], ["z", "a"]], }, { - "input": "\uFFFD=x&\uFFFC&\uFFFD=a", - "output": [["\uFFFC", ""], ["\uFFFD", "x"], ["\uFFFD", "a"]], + "input": "\ufffd=x&\ufffc&\ufffd=a", + "output": [["\ufffc", ""], ["\ufffd", "x"], ["\ufffd", "a"]], }, { "input": "ffi&🌈", @@ -20,8 +20,8 @@ "output": [["🌈", ""], ["ffi", ""]], }, { - "input": "é&e\uFFFD&e\u0301", - "output": [["e\u0301", ""], ["e\uFFFD", ""], ["é", ""]], + "input": "é&e\ufffd&e\u0301", + "output": [["e\u0301", ""], ["e\ufffd", ""], ["é", ""]], }, { "input": "z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g", diff --git a/tests/wpt/test_urlsearchparams_stringifier.py b/tests/wpt/test_urlsearchparams_stringifier.py index d3b5888..fa09126 100644 --- a/tests/wpt/test_urlsearchparams_stringifier.py +++ b/tests/wpt/test_urlsearchparams_stringifier.py @@ -111,10 +111,10 @@ def test_serialize_00(): def test_serialize_d83d_dca9(): """Serialize \\uD83D\\uDCA9""" params = URLSearchParams() - params.append("a", "b\uD83D\uDCA9c") + params.append("a", "b\ud83d\udca9c") assert params + "" == "a=b%F0%9F%92%A9c" params.delete("a") - params.append("a\uD83D\uDCA9b", "c") + params.append("a\ud83d\udca9b", "c") assert params + "" == "a%F0%9F%92%A9b=c"