File tree Expand file tree Collapse file tree 4 files changed +45
-19
lines changed
Expand file tree Collapse file tree 4 files changed +45
-19
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from collections .abc import Sequence
43import functools
54import re
65
6+ TYPE_CHECKING = False
7+ if TYPE_CHECKING :
8+ from collections .abc import Sequence
9+
10+
711DECODE_DEFAULT_CHARS = ";/?:@&=+$,#"
812DECODE_COMPONENT_CHARS = ""
913
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from collections .abc import Sequence
4- from string import ascii_letters , digits , hexdigits
53from urllib .parse import quote as encode_uri_component
64
7- ASCII_LETTERS_AND_DIGITS = ascii_letters + digits
5+ TYPE_CHECKING = False
6+ if TYPE_CHECKING :
7+ from collections .abc import Sequence
8+
9+ ASCII_LETTERS_AND_DIGITS = (
10+ "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"
11+ )
12+ HEXDIGITS = "0123456789" "abcdef" "ABCDEF"
813
914ENCODE_DEFAULT_CHARS = ";/?:@&=+$,-_.!~*'()#"
1015ENCODE_COMPONENT_CHARS = "-_.!~*'()"
@@ -56,7 +61,7 @@ def encode(
5661
5762 # %
5863 if keep_escaped and code == 0x25 and i + 2 < l :
59- if all (c in hexdigits for c in string [i + 1 : i + 3 ]):
64+ if all (c in HEXDIGITS for c in string [i + 1 : i + 3 ]):
6065 result += string [i : i + 3 ]
6166 i += 2
6267 i += 1 # JS for loop statement3
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from typing import TYPE_CHECKING
4-
3+ TYPE_CHECKING = False
54if TYPE_CHECKING :
65 from mdurl ._url import URL
76
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from typing import NamedTuple
4-
5-
6- class URL (NamedTuple ):
7- protocol : str | None
8- slashes : bool
9- auth : str | None
10- port : str | None
11- hostname : str | None
12- hash : str | None # noqa: A003
13- search : str | None
14- pathname : str | None
3+ from collections import namedtuple
4+
5+ TYPE_CHECKING = False
6+ if TYPE_CHECKING :
7+ from typing import NamedTuple
8+
9+ class URL (NamedTuple ):
10+ protocol : str | None
11+ slashes : bool
12+ auth : str | None
13+ port : str | None
14+ hostname : str | None
15+ hash : str | None # noqa: A003
16+ search : str | None
17+ pathname : str | None
18+
19+ else :
20+ URL = namedtuple (
21+ "URL" ,
22+ [
23+ "protocol" ,
24+ "slashes" ,
25+ "auth" ,
26+ "port" ,
27+ "hostname" ,
28+ "hash" ,
29+ "search" ,
30+ "pathname" ,
31+ ],
32+ )
You can’t perform that action at this time.
0 commit comments