Skip to content

Commit d5f8938

Browse files
committed
more type hints
1 parent fe14566 commit d5f8938

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

tests/test_encoding.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ def test_bom(self):
3737
utf32le = b'\xff\xfe\x00\x00\x34\x6c\x00\x00'
3838
for string in (utf16be, utf16le, utf32be, utf32le):
3939
bom_encoding, bom = read_bom(string)
40+
assert bom_encoding is not None
41+
assert bom is not None
4042
decoded = string[len(bom):].decode(bom_encoding)
4143
self.assertEqual(water_unicode, decoded)
4244
# Body without BOM
43-
enc, bom = read_bom("foo")
45+
enc, bom = read_bom(b"foo")
4446
self.assertEqual(enc, None)
4547
self.assertEqual(bom, None)
4648
# Empty body
47-
enc, bom = read_bom("")
49+
enc, bom = read_bom(b"")
4850
self.assertEqual(enc, None)
4951
self.assertEqual(bom, None)
5052

tests/test_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22
from collections import OrderedDict
3-
from w3lib.http import (basic_auth_header,
3+
from w3lib.http import (HeadersDictInput, basic_auth_header,
44
headers_dict_to_raw, headers_raw_to_dict)
55

66
__doctests__ = ['w3lib.http'] # for trial support
@@ -43,7 +43,7 @@ def test_headers_dict_to_raw(self):
4343
)
4444

4545
def test_headers_dict_to_raw_listtuple(self):
46-
dct = OrderedDict([
46+
dct: HeadersDictInput = OrderedDict([
4747
(b'Content-type', [b'text/html']),
4848
(b'Accept', [b'gzip'])
4949
])
@@ -80,7 +80,7 @@ def test_headers_dict_to_raw_listtuple(self):
8080
)
8181

8282
def test_headers_dict_to_raw_wrong_values(self):
83-
dct = OrderedDict([
83+
dct: HeadersDictInput = OrderedDict([
8484
(b'Content-type', 0),
8585
])
8686
self.assertEqual(

tests/test_url.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def test_add_or_replace_parameters(self):
370370
def test_add_or_replace_parameters_does_not_change_input_param(self):
371371
url = 'http://domain/test?arg=original'
372372
input_param = {'arg': 'value'}
373-
new_url = add_or_replace_parameters(url, input_param) # noqa
373+
add_or_replace_parameters(url, input_param) # noqa
374374
self.assertEqual(input_param, {'arg': 'value'})
375375

376376
def test_url_query_cleaner(self):
@@ -568,11 +568,14 @@ def test_normalize_percent_encoding_in_query_arguments(self):
568568

569569
def test_non_ascii_percent_encoding_in_paths(self):
570570
self.assertEqual(canonicalize_url("http://www.example.com/a do?a=1"),
571-
"http://www.example.com/a%20do?a=1"),
571+
"http://www.example.com/a%20do?a=1")
572+
572573
self.assertEqual(canonicalize_url("http://www.example.com/a %20do?a=1"),
573-
"http://www.example.com/a%20%20do?a=1"),
574+
"http://www.example.com/a%20%20do?a=1")
575+
574576
self.assertEqual(canonicalize_url("http://www.example.com/a do£.html?a=1"),
575577
"http://www.example.com/a%20do%C2%A3.html?a=1")
578+
576579
self.assertEqual(canonicalize_url(b"http://www.example.com/a do\xc2\xa3.html?a=1"),
577580
"http://www.example.com/a%20do%C2%A3.html?a=1")
578581

0 commit comments

Comments
 (0)