Skip to content

Commit 0cac45d

Browse files
committed
Revert docstring changes
1 parent a628b22 commit 0cac45d

1 file changed

Lines changed: 100 additions & 95 deletions

File tree

src/hyperlink/_url.py

Lines changed: 100 additions & 95 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: A string representation of the scheme.
481+
text (Text): A string representation of the scheme.
482482
(the 'http' in 'http://hatnote.com')
483-
uses_netloc: Does the scheme support specifying a
483+
uses_netloc (bool): Does the scheme support specifying a
484484
network host? For instance, "http" does, "mailto" does
485485
not. Defaults to True.
486-
default_port: The default port, if any, for
486+
default_port (Optional[int]): The default port, if any, for
487487
netloc-using schemes.
488488
489489
.. _file an issue: https://github.com/mahmoud/hyperlink/issues
@@ -927,36 +927,38 @@ class URL(object):
927927
constructor arguments is below.
928928
929929
Args:
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.
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.
960962
961963
.. _RFC 3986: https://tools.ietf.org/html/rfc3986
962964
.. _RFC 3987: https://tools.ietf.org/html/rfc3987
@@ -1185,9 +1187,9 @@ def authority(self, with_password=False, **kw):
11851187
u'user:pass@localhost:8080'
11861188
11871189
Args:
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.
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.
11911193
11921194
Returns:
11931195
Text: The authority (network location and user information) portion
@@ -1296,29 +1298,32 @@ def replace(
12961298
the value on the current URL.
12971299
12981300
Args:
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.
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.
13221327
13231328
Returns:
13241329
URL: A copy of the current :class:`URL`, with new values for
@@ -1358,7 +1363,7 @@ def from_text(cls, text):
13581363
sure to decode those bytestrings.
13591364
13601365
Args:
1361-
text: A valid URL string.
1366+
text (Text): A valid URL string.
13621367
13631368
Returns:
13641369
URL: The structured object version of the parsed string.
@@ -1464,14 +1469,15 @@ def normalize(
14641469
name.
14651470
14661471
Args:
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`).
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).
14751481
14761482
>>> url = URL.from_text(u'Http://example.COM/a/../b/./c%2f?%61%')
14771483
>>> print(url.normalize().to_text())
@@ -1531,9 +1537,9 @@ def child(self, *segments):
15311537
u'http://localhost/a/b/c/d?x=y'
15321538
15331539
Args:
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.
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.
15371543
15381544
Returns:
15391545
URL: A copy of the current URL with the extra path segments.
@@ -1556,7 +1562,7 @@ def sibling(self, segment):
15561562
sibling of this URL path.
15571563
15581564
Args:
1559-
segment: A single path segment.
1565+
segment (Text): A single path segment.
15601566
15611567
Returns:
15621568
URL: A copy of the current URL with the last path segment
@@ -1855,11 +1861,11 @@ def add(self, name, value=None):
18551861
URL.from_text(u'https://example.com/?x=y&x=z')
18561862
18571863
Args:
1858-
name: The name of the query parameter to add.
1864+
name (Text): The name of the query parameter to add.
18591865
The part before the ``=``.
1860-
value: The value of the query parameter to add.
1861-
The part after the ``=``.
1862-
Defaults to ``None``, meaning no value.
1866+
value (Optional[Text]): The value of the query parameter to add.
1867+
The part after the ``=``. Defaults to ``None``, meaning no
1868+
value.
18631869
18641870
Returns:
18651871
URL: A new :class:`URL` instance with the parameter added.
@@ -1878,11 +1884,11 @@ def set(self, name, value=None):
18781884
URL.from_text(u'https://example.com/?x=z')
18791885
18801886
Args:
1881-
name: The name of the query parameter to set.
1887+
name (Text): The name of the query parameter to set.
18821888
The part before the ``=``.
1883-
value: The value of the query parameter to set.
1884-
The part after the ``=``.
1885-
Defaults to ``None``, meaning no value.
1889+
value (Optional[Text]): The value of the query parameter to set.
1890+
The part after the ``=``. Defaults to ``None``, meaning no
1891+
value.
18861892
18871893
Returns:
18881894
URL: A new :class:`URL` instance with the parameter set.
@@ -1909,7 +1915,7 @@ def get(self, name):
19091915
list is always returned, and this method raises no exceptions.
19101916
19111917
Args:
1912-
name: The name of the query parameter to get.
1918+
name (Text): The name of the query parameter to get.
19131919
19141920
Returns:
19151921
List[Optional[Text]]: A list of all the values associated with the
@@ -1930,11 +1936,12 @@ def remove(
19301936
parameter is not already set.
19311937
19321938
Args:
1933-
name: The name of the query parameter to remove.
1934-
value: Optional value to additionally filter on.
1939+
name (Text): The name of the query parameter to remove.
1940+
value (Text): Optional value to additionally filter on.
19351941
Setting this removes query parameters which match both name
19361942
and value.
1937-
limit: Optional maximum number of parameters to remove.
1943+
limit (Optional[int]): Optional maximum number of parameters to
1944+
remove.
19381945
19391946
Returns:
19401947
URL: A new :class:`URL` instance with the parameter removed.
@@ -1994,10 +2001,9 @@ class DecodedURL(object):
19942001
special characters encoded with codecs other than UTF-8.
19952002
19962003
Args:
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.
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.
20012007
20022008
.. note::
20032009
@@ -2028,10 +2034,9 @@ def from_text(cls, text, lazy=False):
20282034
Make a `DecodedURL` instance from any text string containing a URL.
20292035
20302036
Args:
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.
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.
20352040
"""
20362041
_url = URL.from_text(text)
20372042
return cls(_url, lazy=lazy)
@@ -2381,16 +2386,16 @@ def parse(url, decoded=True, lazy=False):
23812386
https://github.com/python-hyper/hyperlink
23822387
23832388
Args:
2384-
url: A text string representation of a URL.
2389+
url (str): A text string representation of a URL.
23852390
2386-
decoded: Whether or not to return a :class:`DecodedURL`,
2391+
decoded (bool): Whether or not to return a :class:`DecodedURL`,
23872392
which automatically handles all
23882393
encoding/decoding/quoting/unquoting for all the various
23892394
accessors of parts of the URL, or a :class:`URL`,
23902395
which has the same API, but requires handling of special
23912396
characters for different parts of the URL.
23922397
2393-
lazy: In the case of `decoded=True`, this controls
2398+
lazy (bool): In the case of `decoded=True`, this controls
23942399
whether the URL is decoded immediately or as accessed. The
23952400
default, `lazy=False`, checks all encoded parts of the URL
23962401
for decodability.

0 commit comments

Comments
 (0)