Change venv

This commit is contained in:
Ambulance Clerc
2023-05-31 08:31:22 +02:00
parent fb6f579089
commit fdbb52c96f
466 changed files with 25899 additions and 64721 deletions

View File

@@ -7,8 +7,7 @@ _unicode_dots_re = re.compile('[\u002e\u3002\uff0e\uff61]')
class Codec(codecs.Codec):
def encode(self, data, errors='strict'):
# type: (str, str) -> Tuple[bytes, int]
def encode(self, data: str, errors: str = 'strict') -> Tuple[bytes, int]:
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
@@ -17,8 +16,7 @@ class Codec(codecs.Codec):
return encode(data), len(data)
def decode(self, data, errors='strict'):
# type: (bytes, str) -> Tuple[str, int]
def decode(self, data: bytes, errors: str = 'strict') -> Tuple[str, int]:
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
@@ -28,8 +26,7 @@ class Codec(codecs.Codec):
return decode(data), len(data)
class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
def _buffer_encode(self, data, errors, final): # type: ignore
# type: (str, str, bool) -> Tuple[str, int]
def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
@@ -62,8 +59,7 @@ class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
return result_str, size
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
def _buffer_decode(self, data, errors, final): # type: ignore
# type: (str, str, bool) -> Tuple[str, int]
def _buffer_decode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
if errors != 'strict':
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
@@ -103,8 +99,7 @@ class StreamReader(Codec, codecs.StreamReader):
pass
def getregentry():
# type: () -> codecs.CodecInfo
def getregentry() -> codecs.CodecInfo:
# Compatibility as a search_function for codecs.register()
return codecs.CodecInfo(
name='idna',

View File

@@ -2,15 +2,12 @@ from .core import *
from .codec import *
from typing import Any, Union
def ToASCII(label):
# type: (str) -> bytes
def ToASCII(label: str) -> bytes:
return encode(label)
def ToUnicode(label):
# type: (Union[bytes, bytearray]) -> str
def ToUnicode(label: Union[bytes, bytearray]) -> str:
return decode(label)
def nameprep(s):
# type: (Any) -> None
def nameprep(s: Any) -> None:
raise NotImplementedError('IDNA 2008 does not utilise nameprep protocol')

View File

@@ -29,43 +29,36 @@ class InvalidCodepointContext(IDNAError):
pass
def _combining_class(cp):
# type: (int) -> int
def _combining_class(cp: int) -> int:
v = unicodedata.combining(chr(cp))
if v == 0:
if not unicodedata.name(chr(cp)):
raise ValueError('Unknown character in unicodedata')
return v
def _is_script(cp, script):
# type: (str, str) -> bool
def _is_script(cp: str, script: str) -> bool:
return intranges_contain(ord(cp), idnadata.scripts[script])
def _punycode(s):
# type: (str) -> bytes
def _punycode(s: str) -> bytes:
return s.encode('punycode')
def _unot(s):
# type: (int) -> str
def _unot(s: int) -> str:
return 'U+{:04X}'.format(s)
def valid_label_length(label):
# type: (Union[bytes, str]) -> bool
def valid_label_length(label: Union[bytes, str]) -> bool:
if len(label) > 63:
return False
return True
def valid_string_length(label, trailing_dot):
# type: (Union[bytes, str], bool) -> bool
def valid_string_length(label: Union[bytes, str], trailing_dot: bool) -> bool:
if len(label) > (254 if trailing_dot else 253):
return False
return True
def check_bidi(label, check_ltr=False):
# type: (str, bool) -> bool
def check_bidi(label: str, check_ltr: bool = False) -> bool:
# Bidi rules should only be applied if string contains RTL characters
bidi_label = False
for (idx, cp) in enumerate(label, 1):
@@ -124,15 +117,13 @@ def check_bidi(label, check_ltr=False):
return True
def check_initial_combiner(label):
# type: (str) -> bool
def check_initial_combiner(label: str) -> bool:
if unicodedata.category(label[0])[0] == 'M':
raise IDNAError('Label begins with an illegal combining character')
return True
def check_hyphen_ok(label):
# type: (str) -> bool
def check_hyphen_ok(label: str) -> bool:
if label[2:4] == '--':
raise IDNAError('Label has disallowed hyphens in 3rd and 4th position')
if label[0] == '-' or label[-1] == '-':
@@ -140,14 +131,12 @@ def check_hyphen_ok(label):
return True
def check_nfc(label):
# type: (str) -> None
def check_nfc(label: str) -> None:
if unicodedata.normalize('NFC', label) != label:
raise IDNAError('Label must be in Normalization Form C')
def valid_contextj(label, pos):
# type: (str, int) -> bool
def valid_contextj(label: str, pos: int) -> bool:
cp_value = ord(label[pos])
if cp_value == 0x200c:
@@ -190,8 +179,7 @@ def valid_contextj(label, pos):
return False
def valid_contexto(label, pos, exception=False):
# type: (str, int, bool) -> bool
def valid_contexto(label: str, pos: int, exception: bool = False) -> bool:
cp_value = ord(label[pos])
if cp_value == 0x00b7:
@@ -233,8 +221,7 @@ def valid_contexto(label, pos, exception=False):
return False
def check_label(label):
# type: (Union[str, bytes, bytearray]) -> None
def check_label(label: Union[str, bytes, bytearray]) -> None:
if isinstance(label, (bytes, bytearray)):
label = label.decode('utf-8')
if len(label) == 0:
@@ -265,8 +252,7 @@ def check_label(label):
check_bidi(label)
def alabel(label):
# type: (str) -> bytes
def alabel(label: str) -> bytes:
try:
label_bytes = label.encode('ascii')
ulabel(label_bytes)
@@ -290,8 +276,7 @@ def alabel(label):
return label_bytes
def ulabel(label):
# type: (Union[str, bytes, bytearray]) -> str
def ulabel(label: Union[str, bytes, bytearray]) -> str:
if not isinstance(label, (bytes, bytearray)):
try:
label_bytes = label.encode('ascii')
@@ -312,13 +297,15 @@ def ulabel(label):
check_label(label_bytes)
return label_bytes.decode('ascii')
label = label_bytes.decode('punycode')
try:
label = label_bytes.decode('punycode')
except UnicodeError:
raise IDNAError('Invalid A-label')
check_label(label)
return label
def uts46_remap(domain, std3_rules=True, transitional=False):
# type: (str, bool, bool) -> str
def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False) -> str:
"""Re-map the characters in the string according to UTS46 processing."""
from .uts46data import uts46data
output = ''
@@ -350,10 +337,12 @@ def uts46_remap(domain, std3_rules=True, transitional=False):
return unicodedata.normalize('NFC', output)
def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
# type: (Union[str, bytes, bytearray], bool, bool, bool, bool) -> bytes
def encode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool = False, std3_rules: bool = False, transitional: bool = False) -> bytes:
if isinstance(s, (bytes, bytearray)):
s = s.decode('ascii')
try:
s = s.decode('ascii')
except UnicodeDecodeError:
raise IDNAError('should pass a unicode string to the function rather than a byte string.')
if uts46:
s = uts46_remap(s, std3_rules, transitional)
trailing_dot = False
@@ -381,10 +370,12 @@ def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
return s
def decode(s, strict=False, uts46=False, std3_rules=False):
# type: (Union[str, bytes, bytearray], bool, bool, bool) -> str
if isinstance(s, (bytes, bytearray)):
s = s.decode('ascii')
def decode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool = False, std3_rules: bool = False) -> str:
try:
if isinstance(s, (bytes, bytearray)):
s = s.decode('ascii')
except UnicodeDecodeError:
raise IDNAError('Invalid ASCII in A-label')
if uts46:
s = uts46_remap(s, std3_rules, False)
trailing_dot = False

View File

@@ -1,6 +1,6 @@
# This file is automatically generated by tools/idna-data
__version__ = '13.0.0'
__version__ = '15.0.0'
scripts = {
'Greek': (
0x37000000374,
@@ -49,17 +49,19 @@ scripts = {
0x30210000302a,
0x30380000303c,
0x340000004dc0,
0x4e0000009ffd,
0x4e000000a000,
0xf9000000fa6e,
0xfa700000fada,
0x16fe200016fe4,
0x16ff000016ff2,
0x200000002a6de,
0x2a7000002b735,
0x200000002a6e0,
0x2a7000002b73a,
0x2b7400002b81e,
0x2b8200002cea2,
0x2ceb00002ebe1,
0x2f8000002fa1e,
0x300000003134b,
0x31350000323b0,
),
'Hebrew': (
0x591000005c8,
@@ -75,7 +77,8 @@ scripts = {
'Hiragana': (
0x304100003097,
0x309d000030a0,
0x1b0010001b11f,
0x1b0010001b120,
0x1b1320001b133,
0x1b1500001b153,
0x1f2000001f201,
),
@@ -87,7 +90,12 @@ scripts = {
0x330000003358,
0xff660000ff70,
0xff710000ff9e,
0x1aff00001aff4,
0x1aff50001affc,
0x1affd0001afff,
0x1b0000001b001,
0x1b1200001b123,
0x1b1550001b156,
0x1b1640001b168,
),
}
@@ -405,6 +413,39 @@ joining_types = {
0x868: 68,
0x869: 82,
0x86a: 82,
0x870: 82,
0x871: 82,
0x872: 82,
0x873: 82,
0x874: 82,
0x875: 82,
0x876: 82,
0x877: 82,
0x878: 82,
0x879: 82,
0x87a: 82,
0x87b: 82,
0x87c: 82,
0x87d: 82,
0x87e: 82,
0x87f: 82,
0x880: 82,
0x881: 82,
0x882: 82,
0x883: 67,
0x884: 67,
0x885: 67,
0x886: 68,
0x887: 85,
0x888: 85,
0x889: 68,
0x88a: 68,
0x88b: 68,
0x88c: 68,
0x88d: 68,
0x88e: 82,
0x890: 85,
0x891: 85,
0x8a0: 68,
0x8a1: 68,
0x8a2: 68,
@@ -426,6 +467,7 @@ joining_types = {
0x8b2: 82,
0x8b3: 68,
0x8b4: 68,
0x8b5: 68,
0x8b6: 68,
0x8b7: 68,
0x8b8: 68,
@@ -444,6 +486,7 @@ joining_types = {
0x8c5: 68,
0x8c6: 68,
0x8c7: 68,
0x8c8: 68,
0x8e2: 85,
0x1806: 85,
0x1807: 68,
@@ -768,6 +811,24 @@ joining_types = {
0x10f52: 68,
0x10f53: 68,
0x10f54: 82,
0x10f70: 68,
0x10f71: 68,
0x10f72: 68,
0x10f73: 68,
0x10f74: 82,
0x10f75: 82,
0x10f76: 68,
0x10f77: 68,
0x10f78: 68,
0x10f79: 68,
0x10f7a: 68,
0x10f7b: 68,
0x10f7c: 68,
0x10f7d: 68,
0x10f7e: 68,
0x10f7f: 68,
0x10f80: 68,
0x10f81: 68,
0x10fb0: 68,
0x10fb1: 85,
0x10fb2: 68,
@@ -1168,9 +1229,9 @@ codepoint_classes = {
0x8000000082e,
0x8400000085c,
0x8600000086b,
0x8a0000008b5,
0x8b6000008c8,
0x8d3000008e2,
0x87000000888,
0x8890000088f,
0x898000008e2,
0x8e300000958,
0x96000000964,
0x96600000970,
@@ -1252,11 +1313,12 @@ codepoint_classes = {
0xc0e00000c11,
0xc1200000c29,
0xc2a00000c3a,
0xc3d00000c45,
0xc3c00000c45,
0xc4600000c49,
0xc4a00000c4e,
0xc5500000c57,
0xc5800000c5b,
0xc5d00000c5e,
0xc6000000c64,
0xc6600000c70,
0xc8000000c84,
@@ -1269,10 +1331,10 @@ codepoint_classes = {
0xcc600000cc9,
0xcca00000cce,
0xcd500000cd7,
0xcde00000cdf,
0xcdd00000cdf,
0xce000000ce4,
0xce600000cf0,
0xcf100000cf3,
0xcf100000cf4,
0xd0000000d0d,
0xd0e00000d11,
0xd1200000d45,
@@ -1307,7 +1369,7 @@ codepoint_classes = {
0xeb400000ebe,
0xec000000ec5,
0xec600000ec7,
0xec800000ece,
0xec800000ecf,
0xed000000eda,
0xede00000ee0,
0xf0000000f01,
@@ -1366,9 +1428,8 @@ codepoint_classes = {
0x16810000169b,
0x16a0000016eb,
0x16f1000016f9,
0x17000000170d,
0x170e00001715,
0x172000001735,
0x170000001716,
0x171f00001735,
0x174000001754,
0x17600000176d,
0x176e00001771,
@@ -1397,8 +1458,8 @@ codepoint_classes = {
0x1a9000001a9a,
0x1aa700001aa8,
0x1ab000001abe,
0x1abf00001ac1,
0x1b0000001b4c,
0x1abf00001acf,
0x1b0000001b4d,
0x1b5000001b5a,
0x1b6b00001b74,
0x1b8000001bf4,
@@ -1413,8 +1474,7 @@ codepoint_classes = {
0x1d4e00001d4f,
0x1d6b00001d78,
0x1d7900001d9b,
0x1dc000001dfa,
0x1dfb00001e00,
0x1dc000001e00,
0x1e0100001e02,
0x1e0300001e04,
0x1e0500001e06,
@@ -1563,7 +1623,7 @@ codepoint_classes = {
0x1ff600001ff7,
0x214e0000214f,
0x218400002185,
0x2c3000002c5f,
0x2c3000002c60,
0x2c6100002c62,
0x2c6500002c67,
0x2c6800002c69,
@@ -1652,8 +1712,7 @@ codepoint_classes = {
0x31a0000031c0,
0x31f000003200,
0x340000004dc0,
0x4e0000009ffd,
0xa0000000a48d,
0x4e000000a48d,
0xa4d00000a4fe,
0xa5000000a60d,
0xa6100000a62c,
@@ -1766,9 +1825,16 @@ codepoint_classes = {
0xa7bb0000a7bc,
0xa7bd0000a7be,
0xa7bf0000a7c0,
0xa7c10000a7c2,
0xa7c30000a7c4,
0xa7c80000a7c9,
0xa7ca0000a7cb,
0xa7d10000a7d2,
0xa7d30000a7d4,
0xa7d50000a7d6,
0xa7d70000a7d8,
0xa7d90000a7da,
0xa7f20000a7f5,
0xa7f60000a7f8,
0xa7fa0000a828,
0xa82c0000a82d,
@@ -1796,7 +1862,7 @@ codepoint_classes = {
0xab200000ab27,
0xab280000ab2f,
0xab300000ab5b,
0xab600000ab6a,
0xab600000ab69,
0xabc00000abeb,
0xabec0000abee,
0xabf00000abfa,
@@ -1834,9 +1900,16 @@ codepoint_classes = {
0x104d8000104fc,
0x1050000010528,
0x1053000010564,
0x10597000105a2,
0x105a3000105b2,
0x105b3000105ba,
0x105bb000105bd,
0x1060000010737,
0x1074000010756,
0x1076000010768,
0x1078000010786,
0x10787000107b1,
0x107b2000107bb,
0x1080000010806,
0x1080800010809,
0x1080a00010836,
@@ -1873,14 +1946,16 @@ codepoint_classes = {
0x10e8000010eaa,
0x10eab00010ead,
0x10eb000010eb2,
0x10f0000010f1d,
0x10efd00010f1d,
0x10f2700010f28,
0x10f3000010f51,
0x10f7000010f86,
0x10fb000010fc5,
0x10fe000010ff7,
0x1100000011047,
0x1106600011070,
0x1106600011076,
0x1107f000110bb,
0x110c2000110c3,
0x110d0000110e9,
0x110f0000110fa,
0x1110000011135,
@@ -1894,7 +1969,7 @@ codepoint_classes = {
0x111dc000111dd,
0x1120000011212,
0x1121300011238,
0x1123e0001123f,
0x1123e00011242,
0x1128000011287,
0x1128800011289,
0x1128a0001128e,
@@ -1934,6 +2009,7 @@ codepoint_classes = {
0x117000001171b,
0x1171d0001172c,
0x117300001173a,
0x1174000011747,
0x118000001183b,
0x118c0000118ea,
0x118ff00011907,
@@ -1952,7 +2028,7 @@ codepoint_classes = {
0x11a4700011a48,
0x11a5000011a9a,
0x11a9d00011a9e,
0x11ac000011af9,
0x11ab000011af9,
0x11c0000011c09,
0x11c0a00011c37,
0x11c3800011c41,
@@ -1974,14 +2050,22 @@ codepoint_classes = {
0x11d9300011d99,
0x11da000011daa,
0x11ee000011ef7,
0x11f0000011f11,
0x11f1200011f3b,
0x11f3e00011f43,
0x11f5000011f5a,
0x11fb000011fb1,
0x120000001239a,
0x1248000012544,
0x130000001342f,
0x12f9000012ff1,
0x1300000013430,
0x1344000013456,
0x1440000014647,
0x1680000016a39,
0x16a4000016a5f,
0x16a6000016a6a,
0x16a7000016abf,
0x16ac000016aca,
0x16ad000016aee,
0x16af000016af5,
0x16b0000016b37,
@@ -1999,8 +2083,13 @@ codepoint_classes = {
0x17000000187f8,
0x1880000018cd6,
0x18d0000018d09,
0x1b0000001b11f,
0x1aff00001aff4,
0x1aff50001affc,
0x1affd0001afff,
0x1b0000001b123,
0x1b1320001b133,
0x1b1500001b153,
0x1b1550001b156,
0x1b1640001b168,
0x1b1700001b2fc,
0x1bc000001bc6b,
@@ -2008,33 +2097,45 @@ codepoint_classes = {
0x1bc800001bc89,
0x1bc900001bc9a,
0x1bc9d0001bc9f,
0x1cf000001cf2e,
0x1cf300001cf47,
0x1da000001da37,
0x1da3b0001da6d,
0x1da750001da76,
0x1da840001da85,
0x1da9b0001daa0,
0x1daa10001dab0,
0x1df000001df1f,
0x1df250001df2b,
0x1e0000001e007,
0x1e0080001e019,
0x1e01b0001e022,
0x1e0230001e025,
0x1e0260001e02b,
0x1e0300001e06e,
0x1e08f0001e090,
0x1e1000001e12d,
0x1e1300001e13e,
0x1e1400001e14a,
0x1e14e0001e14f,
0x1e2900001e2af,
0x1e2c00001e2fa,
0x1e4d00001e4fa,
0x1e7e00001e7e7,
0x1e7e80001e7ec,
0x1e7ed0001e7ef,
0x1e7f00001e7ff,
0x1e8000001e8c5,
0x1e8d00001e8d7,
0x1e9220001e94c,
0x1e9500001e95a,
0x1fbf00001fbfa,
0x200000002a6de,
0x2a7000002b735,
0x200000002a6e0,
0x2a7000002b73a,
0x2b7400002b81e,
0x2b8200002cea2,
0x2ceb00002ebe1,
0x300000003134b,
0x31350000323b0,
),
'CONTEXTJ': (
0x200c0000200e,

View File

@@ -8,8 +8,7 @@ in the original list?" in time O(log(# runs)).
import bisect
from typing import List, Tuple
def intranges_from_list(list_):
# type: (List[int]) -> Tuple[int, ...]
def intranges_from_list(list_: List[int]) -> Tuple[int, ...]:
"""Represent a list of integers as a sequence of ranges:
((start_0, end_0), (start_1, end_1), ...), such that the original
integers are exactly those x such that start_i <= x < end_i for some i.
@@ -30,17 +29,14 @@ def intranges_from_list(list_):
return tuple(ranges)
def _encode_range(start, end):
# type: (int, int) -> int
def _encode_range(start: int, end: int) -> int:
return (start << 32) | end
def _decode_range(r):
# type: (int) -> Tuple[int, int]
def _decode_range(r: int) -> Tuple[int, int]:
return (r >> 32), (r & ((1 << 32) - 1))
def intranges_contain(int_, ranges):
# type: (int, Tuple[int, ...]) -> bool
def intranges_contain(int_: int, ranges: Tuple[int, ...]) -> bool:
"""Determine if `int_` falls into one of the ranges in `ranges`."""
tuple_ = _encode_range(int_, 0)
pos = bisect.bisect_left(ranges, tuple_)

View File

@@ -1,2 +1,2 @@
__version__ = '3.2'
__version__ = '3.4'

File diff suppressed because it is too large Load Diff