Skip to content

Commit a0c3942

Browse files
committed
flake8
1 parent d5f8938 commit a0c3942

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

w3lib/encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
import re, codecs, encodings
55
from sys import version_info
6-
from typing import Callable, Match, Optional, Tuple, Union, cast
6+
from typing import Callable, Match, Optional, Tuple, Union, cast
77
from w3lib._types import AnyUnicodeError, StrOrBytes
88
from w3lib.util import to_native_str
99

w3lib/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
HTML5_WHITESPACE = ' \t\n\r\x0c'
2020

2121

22-
def replace_entities(text: AnyStr, keep: Sequence[str] = (), remove_illegal: bool = True, encoding: str ='utf-8'):
22+
def replace_entities(text: AnyStr, keep: Sequence[str] = (), remove_illegal: bool = True, encoding: str = 'utf-8'):
2323
"""Remove entities from the given `text` by converting them to their
2424
corresponding unicode character.
2525

w3lib/http.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
HeadersDictInput = Mapping[bytes, Union[Any, Sequence]]
66
HeadersDictOutput = MutableMapping[bytes, List[bytes]]
77

8+
89
def headers_raw_to_dict(headers_raw: Optional[bytes]) -> Optional[HeadersDictOutput]:
910
r"""
1011
Convert raw headers (single multi-line bytestring)

w3lib/url.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _quote_byte(error: UnicodeError) -> Tuple[str, int]:
4848

4949
_ascii_tab_newline_re = re.compile(r'[\t\n\r]') # see https://infra.spec.whatwg.org/#ascii-tab-or-newline
5050

51-
def safe_url_string(url: StrOrBytes, encoding: str ='utf8', path_encoding: str ='utf8', quote_path: bool = True) -> str:
51+
def safe_url_string(url: StrOrBytes, encoding: str = 'utf8', path_encoding: str = 'utf8', quote_path: bool = True) -> str:
5252
"""Convert the given URL into a legal URL by escaping unsafe characters
5353
according to RFC-3986. Also, ASCII tabs and newlines are removed
5454
as per https://url.spec.whatwg.org/#url-parsing.
@@ -101,7 +101,7 @@ def safe_url_string(url: StrOrBytes, encoding: str ='utf8', path_encoding: str =
101101

102102
_parent_dirs = re.compile(r'/?(\.\./)+')
103103

104-
def safe_download_url(url: StrOrBytes, encoding: str ='utf8', path_encoding: str ='utf8') -> str:
104+
def safe_download_url(url: StrOrBytes, encoding: str = 'utf8', path_encoding: str = 'utf8') -> str:
105105
""" Make a url for download. This will call safe_url_string
106106
and then strip the fragment, if one exists. The path will
107107
be normalised.
@@ -124,7 +124,7 @@ def is_url(text: str) -> bool:
124124
return text.partition("://")[0] in ('file', 'http', 'https')
125125

126126

127-
def url_query_parameter(url: StrOrBytes, parameter: str, default: Optional[str] = None, keep_blank_values: Union[bool, int]=0) -> Optional[str]:
127+
def url_query_parameter(url: StrOrBytes, parameter: str, default: Optional[str] = None, keep_blank_values: Union[bool, int] = 0) -> Optional[str]:
128128
"""Return the value of a url parameter, given the url and parameter name
129129
130130
General case:
@@ -163,7 +163,8 @@ def url_query_parameter(url: StrOrBytes, parameter: str, default: Optional[str]
163163
return default
164164

165165

166-
def url_query_cleaner(url: StrOrBytes, parameterlist: Union[StrOrBytes, Sequence[StrOrBytes]] = (), sep: str = '&', kvsep: str = '=', remove: bool = False, unique: bool = True, keep_fragments: bool = False) -> str:
166+
def url_query_cleaner(
167+
url: StrOrBytes, parameterlist: Union[StrOrBytes, Sequence[StrOrBytes]] = (), sep: str = '&', kvsep: str = '=', remove: bool = False, unique: bool = True, keep_fragments: bool = False) -> str:
167168
"""Clean URL arguments leaving only those passed in the parameterlist keeping order
168169
169170
>>> import w3lib.url

w3lib/util.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
from typing import Optional
33
from w3lib._types import StrOrBytes
44

5-
def str_to_unicode(text: StrOrBytes, encoding: Optional[str] = None, errors: str ='strict') -> str:
5+
6+
def str_to_unicode(
7+
text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict'
8+
) -> str:
69
if encoding is None:
710
encoding = 'utf-8'
811
if isinstance(text, bytes):
912
return text.decode(encoding, errors)
1013
return text
1114

12-
def unicode_to_str(text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict') -> bytes:
15+
def unicode_to_str(
16+
text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict'
17+
) -> bytes:
1318
warn(
1419
"The w3lib.utils.unicode_to_str function is deprecated and "
1520
"will be removed in a future release.",
@@ -22,7 +27,10 @@ def unicode_to_str(text: StrOrBytes, encoding: Optional[str] = None, errors: str
2227
return text.encode(encoding, errors)
2328
return text
2429

25-
def to_unicode(text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict') -> str:
30+
31+
def to_unicode(
32+
text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict'
33+
) -> str:
2634
"""Return the unicode representation of a bytes object `text`. If `text`
2735
is already an unicode object, return it as-is."""
2836
if isinstance(text, str):
@@ -35,7 +43,10 @@ def to_unicode(text: StrOrBytes, encoding: Optional[str] = None, errors: str = '
3543
encoding = 'utf-8'
3644
return text.decode(encoding, errors)
3745

38-
def to_bytes(text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict') -> bytes:
46+
47+
def to_bytes(
48+
text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict'
49+
) -> bytes:
3950
"""Return the binary representation of `text`. If `text`
4051
is already a bytes object, return it as-is."""
4152
if isinstance(text, bytes):
@@ -48,7 +59,10 @@ def to_bytes(text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'st
4859
encoding = 'utf-8'
4960
return text.encode(encoding, errors)
5061

51-
def to_native_str(text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict') -> str:
62+
63+
def to_native_str(
64+
text: StrOrBytes, encoding: Optional[str] = None, errors: str = 'strict'
65+
) -> str:
5266
""" Return str representation of `text` """
5367
warn(
5468
"The w3lib.utils.to_native_str function is deprecated and "

0 commit comments

Comments
 (0)