Skip to content

Commit d2b3f45

Browse files
authored
Comprehensive conversion of documentation to Python documentation norms. (#1266)
1 parent c152b61 commit d2b3f45

73 files changed

Lines changed: 2889 additions & 2841 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dns/asyncbackend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class AsyncLibraryNotFoundError(dns.exception.DNSException):
2727
def get_backend(name: str) -> Backend:
2828
"""Get the specified asynchronous backend.
2929
30-
*name*, a ``str``, the name of the backend. Currently the "trio"
31-
and "asyncio" backends are available.
32-
33-
Raises NotImplementedError if an unknown backend name is specified.
30+
:param name: The name of the backend. Currently ``"trio"`` and
31+
``"asyncio"`` are available.
32+
:type name: str
33+
:raises NotImplementedError: If an unknown backend name is specified.
3434
"""
3535
# pylint: disable=import-outside-toplevel,redefined-outer-name
3636
backend = _backends.get(name)

dns/asyncquery.py

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,18 @@ async def send_udp(
9696
) -> tuple[int, float]:
9797
"""Send a DNS message to the specified UDP socket.
9898
99-
*sock*, a ``dns.asyncbackend.DatagramSocket``.
100-
101-
*what*, a ``bytes`` or ``dns.message.Message``, the message to send.
102-
103-
*destination*, a destination tuple appropriate for the address family
104-
of the socket, specifying where to send the query.
105-
106-
*expiration*, a ``float`` or ``None``, the absolute time at which
107-
a timeout exception should be raised. If ``None``, no timeout will
108-
occur. The expiration value is meaningless for the asyncio backend, as
109-
asyncio's transport sendto() never blocks.
110-
111-
Returns an ``(int, float)`` tuple of bytes sent and the sent time.
99+
:param sock: The socket to use.
100+
:type sock: :py:class:`dns.asyncbackend.DatagramSocket`
101+
:param what: The message to send.
102+
:type what: bytes or :py:class:`dns.message.Message`
103+
:param destination: A destination tuple appropriate for the address
104+
family of the socket.
105+
:param expiration: The absolute time at which to raise a timeout
106+
exception. ``None`` means no timeout (and is meaningless for the
107+
asyncio backend, as ``sendto()`` never blocks there).
108+
:type expiration: float or ``None``
109+
:returns: A ``(bytes_sent, sent_time)`` tuple.
110+
:rtype: tuple[int, float]
112111
"""
113112

114113
if isinstance(what, dns.message.Message):
@@ -133,13 +132,14 @@ async def receive_udp(
133132
) -> Any:
134133
"""Read a DNS message from a UDP socket.
135134
136-
*sock*, a ``dns.asyncbackend.DatagramSocket``.
135+
:param sock: The socket to read from.
136+
:type sock: :py:class:`dns.asyncbackend.DatagramSocket`
137137
138-
See :py:func:`dns.query.receive_udp()` for the documentation of the other
139-
parameters, and exceptions.
138+
See :py:func:`dns.query.receive_udp` for the documentation of the other
139+
parameters and exceptions.
140140
141-
Returns a ``(dns.message.Message, float, tuple)`` tuple of the received message, the
142-
received time, and the address where the message arrived from.
141+
:returns: A ``(message, received_time, from_address)`` tuple.
142+
:rtype: tuple
143143
"""
144144

145145
wire = b""
@@ -197,13 +197,13 @@ async def udp(
197197
) -> dns.message.Message:
198198
"""Return the response obtained after sending a query via UDP.
199199
200-
*sock*, a ``dns.asyncbackend.DatagramSocket``, or ``None``,
201-
the socket to use for the query. If ``None``, the default, a
202-
socket is created. Note that if a socket is provided, the
203-
*source*, *source_port*, and *backend* are ignored.
204-
205-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
206-
the default, then dnspython will use the default backend.
200+
:param sock: The socket to use. If ``None`` (the default), a socket is
201+
created. Note that if a socket is provided, *source*, *source_port*,
202+
and *backend* are ignored.
203+
:type sock: :py:class:`dns.asyncbackend.DatagramSocket` or ``None``
204+
:param backend: The async backend. If ``None`` (the default), dnspython
205+
will use the default backend.
206+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
207207
208208
See :py:func:`dns.query.udp()` for the documentation of the other
209209
parameters, exceptions, and return type of this method.
@@ -264,18 +264,18 @@ async def udp_with_fallback(
264264
"""Return the response to the query, trying UDP first and falling back
265265
to TCP if UDP results in a truncated response.
266266
267-
*udp_sock*, a ``dns.asyncbackend.DatagramSocket``, or ``None``,
268-
the socket to use for the UDP query. If ``None``, the default, a
269-
socket is created. Note that if a socket is provided the *source*,
270-
*source_port*, and *backend* are ignored for the UDP query.
271-
272-
*tcp_sock*, a ``dns.asyncbackend.StreamSocket``, or ``None``, the
273-
socket to use for the TCP query. If ``None``, the default, a
274-
socket is created. Note that if a socket is provided *where*,
275-
*source*, *source_port*, and *backend* are ignored for the TCP query.
276-
277-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
278-
the default, then dnspython will use the default backend.
267+
:param udp_sock: The socket to use for the UDP query. If ``None``
268+
(the default), a socket is created. Note that if a socket is provided,
269+
*source*, *source_port*, and *backend* are ignored for the UDP query.
270+
:type udp_sock: :py:class:`dns.asyncbackend.DatagramSocket` or ``None``
271+
:param tcp_sock: The socket to use for the TCP query. If ``None``
272+
(the default), a socket is created. Note that if a socket is provided,
273+
*where*, *source*, *source_port*, and *backend* are ignored for the
274+
TCP query.
275+
:type tcp_sock: :py:class:`dns.asyncbackend.StreamSocket` or ``None``
276+
:param backend: The async backend. If ``None`` (the default), dnspython
277+
will use the default backend.
278+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
279279
280280
See :py:func:`dns.query.udp_with_fallback()` for the documentation
281281
of the other parameters, exceptions, and return type of this
@@ -321,7 +321,8 @@ async def send_tcp(
321321
) -> tuple[int, float]:
322322
"""Send a DNS message to the specified TCP socket.
323323
324-
*sock*, a ``dns.asyncbackend.StreamSocket``.
324+
:param sock: The socket to use.
325+
:type sock: :py:class:`dns.asyncbackend.StreamSocket`
325326
326327
See :py:func:`dns.query.send_tcp()` for the documentation of the other
327328
parameters, exceptions, and return type of this method.
@@ -364,7 +365,8 @@ async def receive_tcp(
364365
) -> tuple[dns.message.Message, float]:
365366
"""Read a DNS message from a TCP socket.
366367
367-
*sock*, a ``dns.asyncbackend.StreamSocket``.
368+
:param sock: The socket to use.
369+
:type sock: :py:class:`dns.asyncbackend.StreamSocket`
368370
369371
See :py:func:`dns.query.receive_tcp()` for the documentation of the other
370372
parameters, exceptions, and return type of this method.
@@ -399,13 +401,13 @@ async def tcp(
399401
) -> dns.message.Message:
400402
"""Return the response obtained after sending a query via TCP.
401403
402-
*sock*, a ``dns.asyncbacket.StreamSocket``, or ``None``, the
403-
socket to use for the query. If ``None``, the default, a socket
404-
is created. Note that if a socket is provided
405-
*where*, *port*, *source*, *source_port*, and *backend* are ignored.
406-
407-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
408-
the default, then dnspython will use the default backend.
404+
:param sock: The socket to use. If ``None`` (the default), a socket is
405+
created. Note that if a socket is provided, *where*, *port*,
406+
*source*, *source_port*, and *backend* are ignored.
407+
:type sock: :py:class:`dns.asyncbackend.StreamSocket` or ``None``
408+
:param backend: The async backend. If ``None`` (the default), dnspython
409+
will use the default backend.
410+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
409411
410412
See :py:func:`dns.query.tcp()` for the documentation of the other
411413
parameters, exceptions, and return type of this method.
@@ -463,15 +465,14 @@ async def tls(
463465
) -> dns.message.Message:
464466
"""Return the response obtained after sending a query via TLS.
465467
466-
*sock*, an ``asyncbackend.StreamSocket``, or ``None``, the socket
467-
to use for the query. If ``None``, the default, a socket is
468-
created. Note that if a socket is provided, it must be a
469-
connected SSL stream socket, and *where*, *port*,
470-
*source*, *source_port*, *backend*, *ssl_context*, and *server_hostname*
471-
are ignored.
472-
473-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
474-
the default, then dnspython will use the default backend.
468+
:param sock: The socket to use. If ``None`` (the default), a socket is
469+
created. Note that if a socket is provided, it must be a connected
470+
SSL stream socket, and *where*, *port*, *source*, *source_port*,
471+
*backend*, *ssl_context*, and *server_hostname* are ignored.
472+
:type sock: :py:class:`dns.asyncbackend.StreamSocket` or ``None``
473+
:param backend: The async backend. If ``None`` (the default), dnspython
474+
will use the default backend.
475+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
475476
476477
See :py:func:`dns.query.tls()` for the documentation of the other
477478
parameters, exceptions, and return type of this method.
@@ -550,11 +551,10 @@ async def https(
550551
) -> dns.message.Message:
551552
"""Return the response obtained after sending a query via DNS-over-HTTPS.
552553
553-
*client*, a ``httpx.AsyncClient``. If provided, the client to use for
554-
the query.
555-
556-
Unlike the other dnspython async functions, a backend cannot be provided
557-
in this function because httpx always auto-detects the async backend.
554+
:param client: If provided, the client to use for the query. Unlike the
555+
other dnspython async functions, a backend cannot be provided here
556+
because httpx always auto-detects the async backend.
557+
:type client: ``httpx.AsyncClient`` or ``None``
558558
559559
See :py:func:`dns.query.https()` for the documentation of the other
560560
parameters, exceptions, and return type of this method.
@@ -788,8 +788,9 @@ async def quic(
788788
"""Return the response obtained after sending an asynchronous query via
789789
DNS-over-QUIC.
790790
791-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
792-
the default, then dnspython will use the default backend.
791+
:param backend: The async backend. If ``None`` (the default), dnspython
792+
will use the default backend.
793+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
793794
794795
See :py:func:`dns.query.quic()` for the documentation of the other
795796
parameters, exceptions, and return type of this method.
@@ -910,8 +911,9 @@ async def inbound_xfr(
910911
"""Conduct an inbound transfer and apply it via a transaction from the
911912
txn_manager.
912913
913-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
914-
the default, then dnspython will use the default backend.
914+
:param backend: The async backend. If ``None`` (the default), dnspython
915+
will use the default backend.
916+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
915917
916918
See :py:func:`dns.query.inbound_xfr()` for the documentation of
917919
the other parameters, exceptions, and return type of this method.

dns/asyncresolver.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ async def resolve(
5959
) -> dns.resolver.Answer:
6060
"""Query nameservers asynchronously to find the answer to the question.
6161
62-
*backend*, a ``dns.asyncbackend.Backend``, or ``None``. If ``None``,
63-
the default, then dnspython will use the default backend.
62+
:param backend: The async backend. If ``None`` (the default), dnspython
63+
will use the default backend.
64+
:type backend: :py:class:`dns.asyncbackend.Backend` or ``None``
6465
6566
See :py:func:`dns.resolver.Resolver.resolve()` for the
6667
documentation of the other parameters, exceptions, and return
@@ -118,8 +119,8 @@ async def resolve_address(
118119
This utilizes the resolve() method to perform a PTR lookup on the
119120
specified IP address.
120121
121-
*ipaddr*, a ``str``, the IPv4 or IPv6 address you want to get
122-
the PTR record for.
122+
:param ipaddr: The IPv4 or IPv6 address to look up.
123+
:type ipaddr: str
123124
124125
All other arguments that can be passed to the resolve() function
125126
except for rdtype and rdclass are also supported by this
@@ -148,10 +149,11 @@ async def resolve_name(
148149
This utilizes the resolve() method to perform A and/or AAAA lookups on
149150
the specified name.
150151
151-
*qname*, a ``dns.name.Name`` or ``str``, the name to resolve.
152-
153-
*family*, an ``int``, the address family. If socket.AF_UNSPEC
154-
(the default), both A and AAAA records will be retrieved.
152+
:param name: The name to resolve.
153+
:type name: :py:class:`dns.name.Name` or str
154+
:param family: The address family. If ``socket.AF_UNSPEC`` (the
155+
default), both A and AAAA records will be retrieved.
156+
:type family: int
155157
156158
All other arguments that can be passed to the resolve() function
157159
except for rdtype and rdclass are also supported by this
@@ -212,13 +214,13 @@ async def canonical_name(self, name: dns.name.Name | str) -> dns.name.Name:
212214
The canonical name is the name the resolver uses for queries
213215
after all CNAME and DNAME renamings have been applied.
214216
215-
*name*, a ``dns.name.Name`` or ``str``, the query name.
216-
217-
This method can raise any exception that ``resolve()`` can
218-
raise, other than ``dns.resolver.NoAnswer`` and
219-
``dns.resolver.NXDOMAIN``.
217+
:param name: The query name.
218+
:type name: :py:class:`dns.name.Name` or str
219+
:rtype: :py:class:`dns.name.Name`
220220
221-
Returns a ``dns.name.Name``.
221+
This method can raise any exception that
222+
:py:meth:`~dns.asyncresolver.Resolver.resolve` can raise, other than
223+
:py:exc:`dns.resolver.NoAnswer` and :py:exc:`dns.resolver.NXDOMAIN`.
222224
"""
223225
try:
224226
answer = await self.resolve(name, raise_on_no_answer=False)
@@ -369,7 +371,7 @@ async def zone_for_name(
369371
) -> dns.name.Name:
370372
"""Find the name of the zone which contains the specified name.
371373
372-
See :py:func:`dns.resolver.Resolver.zone_for_name` for more
374+
See :py:func:`dns.resolver.zone_for_name` for more
373375
information on the parameters and possible exceptions.
374376
"""
375377

@@ -404,20 +406,18 @@ async def make_resolver_at(
404406
) -> Resolver:
405407
"""Make a stub resolver using the specified destination as the full resolver.
406408
407-
*where*, a ``dns.name.Name`` or ``str`` the domain name or IP address of the
408-
full resolver.
409-
410-
*port*, an ``int``, the port to use. If not specified, the default is 53.
411-
412-
*family*, an ``int``, the address family to use. This parameter is used if
413-
*where* is not an address. The default is ``socket.AF_UNSPEC`` in which case
414-
the first address returned by ``resolve_name()`` will be used, otherwise the
415-
first address of the specified family will be used.
416-
417-
*resolver*, a ``dns.asyncresolver.Resolver`` or ``None``, the resolver to use for
418-
resolution of hostnames. If not specified, the default resolver will be used.
419-
420-
Returns a ``dns.resolver.Resolver`` or raises an exception.
409+
:param where: The domain name or IP address of the full resolver.
410+
:type where: :py:class:`dns.name.Name` or str
411+
:param port: The port to use. Default is 53.
412+
:type port: int
413+
:param family: The address family. Used only when *where* is not an
414+
address literal. ``socket.AF_UNSPEC`` (default) uses the first
415+
address returned; otherwise the first address of the given family.
416+
:type family: int
417+
:param resolver: The resolver to use for hostname resolution. If
418+
``None``, the default resolver is used.
419+
:type resolver: :py:class:`dns.asyncresolver.Resolver` or ``None``
420+
:rtype: :py:class:`dns.resolver.Resolver`
421421
"""
422422
if resolver is None:
423423
resolver = get_default_resolver()

0 commit comments

Comments
 (0)