Skip to content

Commit 657d142

Browse files
authored
Merge pull request #131 from python-hyper/sphinx3
Update to Sphinx3
2 parents 00ec552 + ac74527 commit 657d142

2 files changed

Lines changed: 96 additions & 101 deletions

File tree

src/hyperlink/_url.py

Lines changed: 95 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,12 @@ def register_scheme(text, uses_netloc=True, default_port=None):
478478
`file an issue`_!
479479
480480
Args:
481-
text (Text): A string representation of the scheme.
481+
text: A string representation of the scheme.
482482
(the 'http' in 'http://hatnote.com')
483-
uses_netloc (bool): Does the scheme support specifying a
483+
uses_netloc: Does the scheme support specifying a
484484
network host? For instance, "http" does, "mailto" does
485485
not. Defaults to True.
486-
default_port (Optional[int]): The default port, if any, for
486+
default_port: The default port, if any, for
487487
netloc-using schemes.
488488
489489
.. _file an issue: https://github.com/mahmoud/hyperlink/issues
@@ -927,38 +927,36 @@ class URL(object):
927927
constructor arguments is below.
928928
929929
Args:
930-
scheme (Optional[Text]): The text name of the scheme.
931-
host (Optional[Text]): The host portion of the network location
932-
port (Optional[int]): The port part of the network location. If
933-
``None`` or no port is passed, the port will default to
934-
the default port of the scheme, if it is known. See the
935-
``SCHEME_PORT_MAP`` and :func:`register_default_port`
936-
for more info.
937-
path (Iterable[Text]): A tuple of strings representing the
938-
slash-separated parts of the path.
939-
query (Sequence[Tuple[Text, Optional[Text]]]): The query parameters, as
940-
a dictionary or as an sequence of key-value pairs.
941-
fragment (Text): The fragment part of the URL.
942-
rooted (bool): A rooted URL is one which indicates an absolute path.
943-
This is True on any URL that includes a host, or any relative URL
944-
that starts with a slash.
945-
userinfo (Text): The username or colon-separated
946-
username:password pair.
947-
uses_netloc (Optional[bool]): Indicates whether ``://`` (the "netloc
948-
separator") will appear to separate the scheme from the *path* in
949-
cases where no host is present. Setting this to ``True`` is a
950-
non-spec-compliant affordance for the common practice of having URIs
951-
that are *not* URLs (cannot have a 'host' part) but nevertheless use
952-
the common ``://`` idiom that most people associate with URLs;
953-
e.g. ``message:`` URIs like ``message://message-id`` being
954-
equivalent to ``message:message-id``. This may be inferred based on
955-
the scheme depending on whether :func:`register_scheme` has been
956-
used to register the scheme and should not be passed directly unless
957-
you know the scheme works like this and you know it has not been
958-
registered.
959-
960-
All of these parts are also exposed as read-only attributes of
961-
URL instances, along with several useful methods.
930+
scheme: The text name of the scheme.
931+
host: The host portion of the network location
932+
port: The port part of the network location. If ``None`` or no port is
933+
passed, the port will default to the default port of the scheme, if
934+
it is known. See the ``SCHEME_PORT_MAP`` and
935+
:func:`register_default_port` for more info.
936+
path: A tuple of strings representing the slash-separated parts of the
937+
path.
938+
query: The query parameters, as a dictionary or as an sequence of
939+
key-value pairs.
940+
fragment: The fragment part of the URL.
941+
rooted: A rooted URL is one which indicates an absolute path.
942+
This is True on any URL that includes a host, or any relative URL
943+
that starts with a slash.
944+
userinfo: The username or colon-separated username:password pair.
945+
uses_netloc: Indicates whether ``://`` (the "netloc separator") will
946+
appear to separate the scheme from the *path* in cases where no
947+
host is present.
948+
Setting this to ``True`` is a non-spec-compliant affordance for the
949+
common practice of having URIs that are *not* URLs (cannot have a
950+
'host' part) but nevertheless use the common ``://`` idiom that
951+
most people associate with URLs; e.g. ``message:`` URIs like
952+
``message://message-id`` being equivalent to ``message:message-id``.
953+
This may be inferred based on the scheme depending on whether
954+
:func:`register_scheme` has been used to register the scheme and
955+
should not be passed directly unless you know the scheme works like
956+
this and you know it has not been registered.
957+
958+
All of these parts are also exposed as read-only attributes of :class:`URL`
959+
instances, along with several useful methods.
962960
963961
.. _RFC 3986: https://tools.ietf.org/html/rfc3986
964962
.. _RFC 3987: https://tools.ietf.org/html/rfc3987
@@ -1187,9 +1185,9 @@ def authority(self, with_password=False, **kw):
11871185
u'user:pass@localhost:8080'
11881186
11891187
Args:
1190-
with_password (bool): Whether the return value of this
1191-
method include the password in the URL, if it is
1192-
set. Defaults to False.
1188+
with_password: Whether the return value of this method include the
1189+
password in the URL, if it is set.
1190+
Defaults to False.
11931191
11941192
Returns:
11951193
Text: The authority (network location and user information) portion
@@ -1298,32 +1296,29 @@ def replace(
12981296
the value on the current URL.
12991297
13001298
Args:
1301-
scheme (Optional[Text]): The text name of the scheme.
1302-
host (Optional[Text]): The host portion of the network location.
1303-
path (Iterable[Text]): A tuple of strings representing the
1304-
slash-separated parts of the path.
1305-
query (Sequence[Tuple[Text, Optional[Text]]]): The query
1306-
parameters, as a dictionary or as an sequence of key-value
1307-
pairs.
1308-
fragment (Text): The fragment part of the URL.
1309-
port (Optional[int]): The port part of the network location.
1310-
rooted (Optional[bool]): Whether or not the path begins with a
1311-
slash.
1312-
userinfo (Text): The username or colon-separated username:password
1313-
pair.
1314-
uses_netloc (bool): Indicates whether ``://`` (the "netloc
1315-
separator") will appear to separate the scheme from the *path*
1316-
in cases where no host is present. Setting this to ``True`` is
1317-
a non-spec-compliant affordance for the common practice of
1318-
having URIs that are *not* URLs (cannot have a 'host' part) but
1319-
nevertheless use the common ``://`` idiom that most people
1320-
associate with URLs; e.g. ``message:`` URIs like
1321-
``message://message-id`` being equivalent to
1322-
``message:message-id``. This may be inferred based on the
1323-
scheme depending on whether :func:`register_scheme` has been
1324-
used to register the scheme and should not be passed directly
1325-
unless you know the scheme works like this and you know it has
1326-
not been registered.
1299+
scheme: The text name of the scheme.
1300+
host: The host portion of the network location.
1301+
path: A tuple of strings representing the slash-separated parts of
1302+
the path.
1303+
query: The query parameters, as a dictionary or as an sequence of
1304+
key-value pairs.
1305+
fragment: The fragment part of the URL.
1306+
port: The port part of the network location.
1307+
rooted: Whether or not the path begins with a slash.
1308+
userinfo: The username or colon-separated username:password pair.
1309+
uses_netloc: Indicates whether ``://`` (the "netloc separator")
1310+
will appear to separate the scheme from the *path* in cases
1311+
where no host is present.
1312+
Setting this to ``True`` is a non-spec-compliant affordance for
1313+
the common practice of having URIs that are *not* URLs (cannot
1314+
have a 'host' part) but nevertheless use the common ``://``
1315+
idiom that most people associate with URLs; e.g. ``message:``
1316+
URIs like ``message://message-id`` being equivalent to
1317+
``message:message-id``.
1318+
This may be inferred based on the scheme depending on whether
1319+
:func:`register_scheme` has been used to register the scheme
1320+
and should not be passed directly unless you know the scheme
1321+
works like this and you know it has not been registered.
13271322
13281323
Returns:
13291324
URL: A copy of the current :class:`URL`, with new values for
@@ -1363,7 +1358,7 @@ def from_text(cls, text):
13631358
sure to decode those bytestrings.
13641359
13651360
Args:
1366-
text (Text): A valid URL string.
1361+
text: A valid URL string.
13671362
13681363
Returns:
13691364
URL: The structured object version of the parsed string.
@@ -1469,15 +1464,14 @@ def normalize(
14691464
name.
14701465
14711466
Args:
1472-
scheme (bool): Convert the scheme to lowercase
1473-
host (bool): Convert the host to lowercase
1474-
path (bool): Normalize the path (see above for details)
1475-
query (bool): Normalize the query string
1476-
fragment (bool): Normalize the fragment
1477-
userinfo (bool): Normalize the userinfo
1478-
percents (bool): Encode isolated percent signs for any
1479-
percent-encoded fields which are being normalized
1480-
(defaults to True).
1467+
scheme: Convert the scheme to lowercase
1468+
host: Convert the host to lowercase
1469+
path: Normalize the path (see above for details)
1470+
query: Normalize the query string
1471+
fragment: Normalize the fragment
1472+
userinfo: Normalize the userinfo
1473+
percents: Encode isolated percent signs for any percent-encoded
1474+
fields which are being normalized (defaults to `True`).
14811475
14821476
>>> url = URL.from_text(u'Http://example.COM/a/../b/./c%2f?%61%')
14831477
>>> print(url.normalize().to_text())
@@ -1537,9 +1531,9 @@ def child(self, *segments):
15371531
u'http://localhost/a/b/c/d?x=y'
15381532
15391533
Args:
1540-
segments (Text): Additional parts to be joined and added to
1541-
the path, like :func:`os.path.join`. Special characters
1542-
in segments will be percent encoded.
1534+
segments: Additional parts to be joined and added to the path, like
1535+
:func:`os.path.join`. Special characters in segments will be
1536+
percent encoded.
15431537
15441538
Returns:
15451539
URL: A copy of the current URL with the extra path segments.
@@ -1562,7 +1556,7 @@ def sibling(self, segment):
15621556
sibling of this URL path.
15631557
15641558
Args:
1565-
segment (Text): A single path segment.
1559+
segment: A single path segment.
15661560
15671561
Returns:
15681562
URL: A copy of the current URL with the last path segment
@@ -1861,11 +1855,11 @@ def add(self, name, value=None):
18611855
URL.from_text(u'https://example.com/?x=y&x=z')
18621856
18631857
Args:
1864-
name (Text): The name of the query parameter to add.
1858+
name: The name of the query parameter to add.
18651859
The part before the ``=``.
1866-
value (Optional[Text]): The value of the query parameter to add.
1867-
The part after the ``=``. Defaults to ``None``, meaning no
1868-
value.
1860+
value: The value of the query parameter to add.
1861+
The part after the ``=``.
1862+
Defaults to ``None``, meaning no value.
18691863
18701864
Returns:
18711865
URL: A new :class:`URL` instance with the parameter added.
@@ -1884,11 +1878,11 @@ def set(self, name, value=None):
18841878
URL.from_text(u'https://example.com/?x=z')
18851879
18861880
Args:
1887-
name (Text): The name of the query parameter to set.
1881+
name: The name of the query parameter to set.
18881882
The part before the ``=``.
1889-
value (Optional[Text]): The value of the query parameter to set.
1890-
The part after the ``=``. Defaults to ``None``, meaning no
1891-
value.
1883+
value: The value of the query parameter to set.
1884+
The part after the ``=``.
1885+
Defaults to ``None``, meaning no value.
18921886
18931887
Returns:
18941888
URL: A new :class:`URL` instance with the parameter set.
@@ -1915,7 +1909,7 @@ def get(self, name):
19151909
list is always returned, and this method raises no exceptions.
19161910
19171911
Args:
1918-
name (Text): The name of the query parameter to get.
1912+
name: The name of the query parameter to get.
19191913
19201914
Returns:
19211915
List[Optional[Text]]: A list of all the values associated with the
@@ -1936,12 +1930,11 @@ def remove(
19361930
parameter is not already set.
19371931
19381932
Args:
1939-
name (Text): The name of the query parameter to remove.
1940-
value (Text): Optional value to additionally filter on.
1933+
name: The name of the query parameter to remove.
1934+
value: Optional value to additionally filter on.
19411935
Setting this removes query parameters which match both name
19421936
and value.
1943-
limit (Optional[int]): Optional maximum number of parameters to
1944-
remove.
1937+
limit: Optional maximum number of parameters to remove.
19451938
19461939
Returns:
19471940
URL: A new :class:`URL` instance with the parameter removed.
@@ -2001,9 +1994,10 @@ class DecodedURL(object):
20011994
special characters encoded with codecs other than UTF-8.
20021995
20031996
Args:
2004-
url (URL): A :class:`URL` object to wrap.
2005-
lazy (bool): Set to True to avoid pre-decode all parts of the URL to
2006-
check for validity. Defaults to False.
1997+
url: A :class:`URL` object to wrap.
1998+
lazy: Set to True to avoid pre-decode all parts of the URL to check for
1999+
validity.
2000+
Defaults to False.
20072001
20082002
.. note::
20092003
@@ -2034,9 +2028,10 @@ def from_text(cls, text, lazy=False):
20342028
Make a `DecodedURL` instance from any text string containing a URL.
20352029
20362030
Args:
2037-
text (Text): Text containing the URL
2038-
lazy (bool): Whether to pre-decode all parts of the URL to check for
2039-
validity. Defaults to True.
2031+
text: Text containing the URL
2032+
lazy: Whether to pre-decode all parts of the URL to check for
2033+
validity.
2034+
Defaults to True.
20402035
"""
20412036
_url = URL.from_text(text)
20422037
return cls(_url, lazy=lazy)
@@ -2386,16 +2381,16 @@ def parse(url, decoded=True, lazy=False):
23862381
https://github.com/python-hyper/hyperlink
23872382
23882383
Args:
2389-
url (str): A text string representation of a URL.
2384+
url: A text string representation of a URL.
23902385
2391-
decoded (bool): Whether or not to return a :class:`DecodedURL`,
2386+
decoded: Whether or not to return a :class:`DecodedURL`,
23922387
which automatically handles all
23932388
encoding/decoding/quoting/unquoting for all the various
23942389
accessors of parts of the URL, or a :class:`URL`,
23952390
which has the same API, but requires handling of special
23962391
characters for different parts of the URL.
23972392
2398-
lazy (bool): In the case of `decoded=True`, this controls
2393+
lazy: In the case of `decoded=True`, this controls
23992394
whether the URL is decoded immediately or as accessed. The
24002395
default, `lazy=False`, checks all encoded parts of the URL
24012396
for decodability.

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ description = build documentation
318318
basepython = {[default]basepython}
319319

320320
deps =
321-
Sphinx==2.4.4
321+
Sphinx==3.0.4
322322
sphinx-rtd-theme==0.5.0
323323

324324
commands =

0 commit comments

Comments
 (0)