Skip to content

Commit 37cf287

Browse files
authored
Merge pull request #75 from python-hyper/format-against-latest-version-of-black
Fix CI status.
2 parents dba3ada + 8b5f2f3 commit 37cf287

File tree

9 files changed

+75
-22
lines changed

9 files changed

+75
-22
lines changed

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pytest
22
pytest-cov>=2.0
3+
attrs==20.1.0

src/rfc3986/_mixin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def authority_is_valid(self, require=False):
152152
return False
153153

154154
return validators.authority_is_valid(
155-
self.authority, host=self.host, require=require,
155+
self.authority,
156+
host=self.host,
157+
require=require,
156158
)
157159

158160
def scheme_is_valid(self, require=False):

src/rfc3986/abnf_regexp.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
2828
DIGIT = "0123456789"
2929
# https://tools.ietf.org/html/rfc3986#section-2.3
30-
UNRESERVED = UNRESERVED_CHARS = ALPHA + DIGIT + r'._!-~'
30+
UNRESERVED = UNRESERVED_CHARS = ALPHA + DIGIT + r"._!-~"
3131
UNRESERVED_CHARS_SET = set(UNRESERVED_CHARS)
3232
NON_PCT_ENCODED_SET = RESERVED_CHARS_SET.union(UNRESERVED_CHARS_SET)
3333
# We need to escape the '-' in this case:
@@ -123,11 +123,16 @@
123123
IPv6_ADDRZ_RFC4007_RE = IPv6_RE + "(?:(?:%25|%)" + ZONE_ID + ")?"
124124
IPv6_ADDRZ_RE = IPv6_RE + "(?:%25" + ZONE_ID + ")?"
125125

126-
IP_LITERAL_RE = r"\[({0}|{1})\]".format(IPv6_ADDRZ_RFC4007_RE, IPv_FUTURE_RE,)
126+
IP_LITERAL_RE = r"\[({0}|{1})\]".format(
127+
IPv6_ADDRZ_RFC4007_RE,
128+
IPv_FUTURE_RE,
129+
)
127130

128131
# Pattern for matching the host piece of the authority
129132
HOST_RE = HOST_PATTERN = "({0}|{1}|{2})".format(
130-
REG_NAME, IPv4_RE, IP_LITERAL_RE,
133+
REG_NAME,
134+
IPv4_RE,
135+
IP_LITERAL_RE,
131136
)
132137
USERINFO_RE = (
133138
"^([" + UNRESERVED_RE + SUB_DELIMITERS_RE + ":]|%s)+" % (PCT_ENCODED)
@@ -237,7 +242,9 @@
237242
)
238243

239244
IHOST_RE = IHOST_PATTERN = u"({0}|{1}|{2})".format(
240-
IREG_NAME, IPv4_RE, IP_LITERAL_RE,
245+
IREG_NAME,
246+
IPv4_RE,
247+
IP_LITERAL_RE,
241248
)
242249

243250
IUSERINFO_RE = (

src/rfc3986/builder.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def add_credentials(self, username, password):
137137

138138
if password is not None:
139139
userinfo = "{}:{}".format(
140-
userinfo, normalizers.normalize_password(password),
140+
userinfo,
141+
normalizers.normalize_password(password),
141142
)
142143

143144
return URIBuilder(
@@ -194,7 +195,9 @@ def add_port(self, port):
194195
if port_int > 65535:
195196
raise ValueError(
196197
"ports are not allowed to be larger than 65535. "
197-
"You provided {}".format(port_int,)
198+
"You provided {}".format(
199+
port_int,
200+
)
198201
)
199202

200203
return URIBuilder(

src/rfc3986/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def __init__(self, component_name, component_value, allowed_values):
7474
"""Initialize the error with the unpermitted component."""
7575
super(UnpermittedComponentError, self).__init__(
7676
"{} was required to be one of {!r} but was {!r}".format(
77-
component_name, list(sorted(allowed_values)), component_value,
77+
component_name,
78+
list(sorted(allowed_values)),
79+
component_value,
7880
),
7981
component_name,
8082
component_value,

src/rfc3986/validators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ def ensure_one_of(allowed_values, uri, attribute):
250250
value = getattr(uri, attribute)
251251
if value is not None and allowed_values and value not in allowed_values:
252252
raise exceptions.UnpermittedComponentError(
253-
attribute, value, allowed_values,
253+
attribute,
254+
value,
255+
allowed_values,
254256
)
255257

256258

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858
"HtTpS",
5959
]
6060
equivalent_schemes_and_hostnames = list(
61-
itertools.product(equivalent_schemes, equivalent_hostnames,)
61+
itertools.product(
62+
equivalent_schemes,
63+
equivalent_hostnames,
64+
)
6265
)
6366

6467

tests/test_builder.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ def test_repr():
6565

6666

6767
@pytest.mark.parametrize(
68-
"scheme", ["https", "hTTps", "Https", "HtTpS", "HTTPS",]
68+
"scheme",
69+
[
70+
"https",
71+
"hTTps",
72+
"Https",
73+
"HtTpS",
74+
"HTTPS",
75+
],
6976
)
7077
def test_add_scheme(scheme):
7178
"""Verify schemes are normalized when added."""
@@ -158,7 +165,11 @@ def test_add_port(port, expected):
158165

159166

160167
@pytest.mark.parametrize(
161-
"path", ["sigmavirus24/rfc3986", "/sigmavirus24/rfc3986",]
168+
"path",
169+
[
170+
"sigmavirus24/rfc3986",
171+
"/sigmavirus24/rfc3986",
172+
],
162173
)
163174
def test_add_path(path):
164175
"""Verify we normalize our path value."""

tests/test_validators.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def test_allowing_schemes():
3131
def test_allowing_hosts():
3232
"""Verify the ability to select hosts to be allowed."""
3333
validator = validators.Validator().allow_hosts(
34-
"pypi.python.org", "pypi.org",
34+
"pypi.python.org",
35+
"pypi.org",
3536
)
3637

3738
assert "pypi.python.org" in validator.allowed_hosts
@@ -161,7 +162,10 @@ def test_multiple_missing_components(uri):
161162

162163
@pytest.mark.parametrize(
163164
"uri",
164-
[rfc3986.uri_reference("smtp://"), rfc3986.uri_reference("telnet://"),],
165+
[
166+
rfc3986.uri_reference("smtp://"),
167+
rfc3986.uri_reference("telnet://"),
168+
],
165169
)
166170
def test_ensure_uri_has_a_scheme(uri):
167171
"""Verify validation with allowed schemes."""
@@ -183,8 +187,14 @@ def test_allowed_hosts_and_schemes(uri, failed_component):
183187
"""Verify each of these fails."""
184188
validator = (
185189
validators.Validator()
186-
.allow_schemes("https", "ssh",)
187-
.allow_hosts("github.com", "git.openstack.org",)
190+
.allow_schemes(
191+
"https",
192+
"ssh",
193+
)
194+
.allow_hosts(
195+
"github.com",
196+
"git.openstack.org",
197+
)
188198
)
189199
with pytest.raises(exceptions.UnpermittedComponentError) as caught_exc:
190200
validator.validate(uri)
@@ -237,11 +247,22 @@ def test_allowed_hosts_and_schemes(uri, failed_component):
237247
def test_successful_complex_validation(uri):
238248
"""Verify we do not raise ValidationErrors for good URIs."""
239249
validators.Validator().allow_schemes("https", "ssh",).allow_hosts(
240-
"github.com", "bitbucket.org", "gitlab.com", "git.openstack.org",
250+
"github.com",
251+
"bitbucket.org",
252+
"gitlab.com",
253+
"git.openstack.org",
241254
).allow_ports("22", "443",).require_presence_of(
242-
"scheme", "host", "path",
255+
"scheme",
256+
"host",
257+
"path",
243258
).check_validity_of(
244-
"scheme", "userinfo", "host", "port", "path", "query", "fragment",
259+
"scheme",
260+
"userinfo",
261+
"host",
262+
"port",
263+
"path",
264+
"query",
265+
"fragment",
245266
).validate(
246267
uri
247268
)
@@ -259,9 +280,10 @@ def test_invalid_uri_with_invalid_path(invalid_uri):
259280
uri = rfc3986.uri_reference(invalid_uri)
260281
uri = uri.copy_with(path="#foobar")
261282
with pytest.raises(exceptions.InvalidComponentsError):
262-
validators.Validator().check_validity_of("host", "path",).validate(
263-
uri
264-
)
283+
validators.Validator().check_validity_of(
284+
"host",
285+
"path",
286+
).validate(uri)
265287

266288

267289
def test_validating_rfc_4007_ipv6_zone_ids():

0 commit comments

Comments
 (0)