Skip to content

Commit 29c3dd9

Browse files
committed
pin pyflakes pending a release with PyCQA/pyflakes#455
Clean up some type hints.
1 parent 322f867 commit 29c3dd9

7 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/hyperlink/_url.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
try:
2424
from socket import AddressFamily
2525
except ImportError:
26-
AddressFamily = int # type: ignore[assignment,misc] Python 2
26+
AddressFamily = int # type: ignore[assignment,misc]
2727
from typing import (
2828
Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional,
2929
Sequence, Text, Tuple, Type, TypeVar, Union, cast,
@@ -97,7 +97,7 @@ def __repr__(self):
9797
if var_name:
9898
# superclass type hints don't allow str return type, but it is
9999
# allowed in the docs, hence the ignore[override] below
100-
def __reduce__(self): # type: ignore[override] intentional
100+
def __reduce__(self): # type: ignore[override]
101101
# type: () -> str
102102
return self.var_name
103103

@@ -110,7 +110,7 @@ def __nonzero__(self):
110110
return Sentinel()
111111

112112

113-
_unspecified = _UNSET = make_sentinel('_UNSET')
113+
_unspecified = _UNSET = make_sentinel('_UNSET') # type: Any
114114

115115

116116
# RFC 3986 Section 2.3, Unreserved URI Characters
@@ -466,15 +466,15 @@ def _textcheck(name, value, delims=frozenset(), nullable=False):
466466
if not isinstance(value, Text):
467467
if nullable and value is None:
468468
# used by query string values
469-
return value # type: ignore[misc] unreachable
469+
return value # type: ignore[misc] # unreachable
470470
else:
471471
str_name = "unicode" if PY2 else "str"
472472
exp = str_name + ' or NoneType' if nullable else str_name
473473
raise TypeError('expected %s for %s, got %r' % (exp, name, value))
474474
if delims and set(value) & set(delims): # TODO: test caching into regexes
475475
raise ValueError('one or more reserved delimiters %s present in %s: %r'
476476
% (''.join(delims), name, value))
477-
return value # type: ignore[return-value] T vs. Text
477+
return value # type: ignore[return-value] # T vs. Text
478478

479479

480480
def iter_pairs(iterable):
@@ -1089,7 +1089,7 @@ def absolute(self):
10891089
"""
10901090
return bool(self.scheme and self.host)
10911091

1092-
def replace( # type: ignore[assignment] _UNSET is private
1092+
def replace(
10931093
self,
10941094
scheme=_UNSET, # type: Optional[Text]
10951095
host=_UNSET, # type: Optional[Text]
@@ -1194,7 +1194,7 @@ def from_text(cls, text):
11941194
port = au_gs['port']
11951195
if port is not None:
11961196
try:
1197-
port = int(port) # type: ignore[assignment] FIXME, also below
1197+
port = int(port) # type: ignore[assignment] # FIXME, see below
11981198
except ValueError:
11991199
if not port: # TODO: excessive?
12001200
raise URLParseError('port must not be empty: %r' % au_text)
@@ -1227,7 +1227,7 @@ def from_text(cls, text):
12271227
query = ()
12281228
return cls(
12291229
scheme, host, path, query, fragment,
1230-
port, # type: ignore[arg-type] FIXME, also above
1230+
port, # type: ignore[arg-type] # FIXME, see above
12311231
rooted, userinfo, uses_netloc,
12321232
)
12331233

@@ -1323,7 +1323,7 @@ def child(self, *segments):
13231323
if not segments:
13241324
return self
13251325

1326-
segments = [ # type: ignore[assignment] variable is tuple
1326+
segments = [ # type: ignore[assignment] # variable is tuple
13271327
_textcheck('path segment', s) for s in segments
13281328
]
13291329
new_path = tuple(self.path)
@@ -1679,7 +1679,7 @@ def get(self, name):
16791679
"""
16801680
return [value for (key, value) in self.query if name == key]
16811681

1682-
def remove( # type: ignore[assignment] _UNSET is private
1682+
def remove(
16831683
self,
16841684
name, # type: Text
16851685
value=_UNSET, # type: Text
@@ -1863,7 +1863,7 @@ def path(self):
18631863
try:
18641864
return cast(
18651865
Tuple[Text, ...],
1866-
self._path # type: ignore[has-type] can't determine
1866+
self._path # type: ignore[has-type] # can't determine
18671867
)
18681868
except AttributeError:
18691869
pass
@@ -1879,7 +1879,7 @@ def query(self):
18791879
try:
18801880
return cast(
18811881
QueryPairs,
1882-
self._query # type: ignore[has-type] can't determine
1882+
self._query # type: ignore[has-type] # can't determine
18831883
)
18841884
except AttributeError:
18851885
pass
@@ -1899,7 +1899,7 @@ def fragment(self):
18991899
try:
19001900
return cast(
19011901
Text,
1902-
self._fragment # type: ignore[has-type] can't determine
1902+
self._fragment # type: ignore[has-type] # can't determine
19031903
)
19041904
except AttributeError:
19051905
pass
@@ -1913,7 +1913,7 @@ def userinfo(self):
19131913
try:
19141914
return cast(
19151915
Union[Tuple[str], Tuple[str, str]],
1916-
self._userinfo # type: ignore[has-type] can't determine
1916+
self._userinfo # type: ignore[has-type] # can't determine
19171917
)
19181918
except AttributeError:
19191919
pass
@@ -1938,7 +1938,7 @@ def uses_netloc(self):
19381938
# type: () -> bool
19391939
return cast(bool, self._url.uses_netloc)
19401940

1941-
def replace( # type: ignore[assignment] _UNSET is private
1941+
def replace(
19421942
self,
19431943
scheme=_UNSET, # type: Optional[Text]
19441944
host=_UNSET, # type: Optional[Text]
@@ -2007,7 +2007,7 @@ def set(self, name, value=None):
20072007
q[idx:idx] = [(name, value)]
20082008
return self.replace(query=q)
20092009

2010-
def remove( # type: ignore[assignment] _UNSET is private
2010+
def remove(
20112011
self,
20122012
name, # type: Text
20132013
value=_UNSET, # type: Text

src/hyperlink/test/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class HyperlinkTestCase(TestCase):
66
"""This type mostly exists to provide a backwards-compatible
77
assertRaises method for Python 2.6 testing.
88
"""
9-
def assertRaises( # type: ignore[override] Doesn't match superclass, meh
9+
def assertRaises( # type: ignore[override]
1010
self, expected_exception, callableObj=None, *args, **kwargs
1111
):
1212
# type: (Type[BaseException], Optional[Callable], Any, Any) -> Any

src/hyperlink/test/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_assertRaisesContextManager(self):
8888
with self.hyperlink_test.assertRaises(_ExpectedException) as cm:
8989
raise _ExpectedException
9090

91-
self.assertTrue( # type: ignore[misc] unreachable
91+
self.assertTrue( # type: ignore[misc] # unreachable
9292
isinstance(cm.exception, _ExpectedException)
9393
)
9494

src/hyperlink/test/test_decoded_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_replace_userinfo(self):
170170
durl = DecodedURL.from_text(TOTAL_URL)
171171
with self.assertRaises(ValueError):
172172
durl.replace(
173-
userinfo=( # type: ignore[arg-type] intentional
173+
userinfo=( # type: ignore[arg-type]
174174
'user', 'pw', 'thiswillcauseafailure'
175175
)
176176
)

src/hyperlink/test/test_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
try:
44
from socket import inet_pton
55
except ImportError:
6-
inet_pton = None # type: ignore[assignment] optional
6+
inet_pton = None # type: ignore[assignment]
77

88
if not inet_pton:
99
import socket

src/hyperlink/test/test_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ def assertRaised(raised, expectation, name):
871871
def check(param, expectation=defaultExpectation):
872872
# type: (Any, str) -> None
873873
with self.assertRaises(TypeError) as raised:
874-
URL(**{param: Unexpected()}) # type: ignore[arg-type] ok
874+
URL(**{param: Unexpected()}) # type: ignore[arg-type]
875875

876876
assertRaised(raised, expectation, param)
877877

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ deps =
8484
mccabe==0.6.1
8585
pep8-naming==0.9.1
8686
pydocstyle==4.0.1
87+
# pin pyflakes pending a release with https://github.com/PyCQA/pyflakes/pull/455
88+
git+git://github.com/PyCQA/pyflakes@ffe9386#egg=pyflakes
8789

8890
commands =
8991
flake8 {posargs:src/{env:PY_MODULE}}

0 commit comments

Comments
 (0)