From: Brian Wellington Date: Fri, 18 Mar 2022 19:48:08 +0000 (-0700) Subject: Add typing info. X-Git-Tag: v2.3.0rc1~89^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F793%2Fhead;p=thirdparty%2Fdnspython.git Add typing info. --- diff --git a/dns/message.py b/dns/message.py index de347441..9541df68 100644 --- a/dns/message.py +++ b/dns/message.py @@ -1586,7 +1586,7 @@ def from_file( """ if isinstance(f, str): - cm = open(f) + cm: contextlib.AbstractContextManager = open(f) else: cm = contextlib.nullcontext(f) with cm as f: diff --git a/dns/query.py b/dns/query.py index 04eaca4a..7dec23e3 100644 --- a/dns/query.py +++ b/dns/query.py @@ -380,7 +380,7 @@ def https( ) if session: - cm = contextlib.nullcontext(session) + cm: contextlib.AbstractContextManager = contextlib.nullcontext(session) elif _is_httpx: cm = httpx.Client( http1=True, http2=_have_http2, verify=verify, transport=transport @@ -631,7 +631,7 @@ def udp( ) (begin_time, expiration) = _compute_times(timeout) if sock: - cm = contextlib.nullcontext(sock) + cm: contextlib.AbstractContextManager = contextlib.nullcontext(sock) else: cm = _make_socket(af, socket.SOCK_DGRAM, source) with cm as s: @@ -914,7 +914,7 @@ def tcp( wire = q.to_wire() (begin_time, expiration) = _compute_times(timeout) if sock: - cm = contextlib.nullcontext(sock) + cm: contextlib.AbstractContextManager = contextlib.nullcontext(sock) else: (af, destination, source) = _destination_and_source( where, port, source, source_port diff --git a/dns/resolver.py b/dns/resolver.py index 74fbd336..350cc33b 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -905,7 +905,7 @@ class BaseResolver: if isinstance(f, str): try: - cm = open(f) + cm: contextlib.AbstractContextManager = open(f) except OSError: # /etc/resolv.conf doesn't exist, can't be read, etc. raise NoResolverConfiguration(f"cannot open {f}") diff --git a/dns/zone.py b/dns/zone.py index 76386b64..fe6c16af 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -642,7 +642,7 @@ class Zone(dns.transaction.TransactionManager): """ if isinstance(f, str): - cm = open(f, "wb") + cm: contextlib.AbstractContextManager = open(f, "wb") else: cm = contextlib.nullcontext(f) with cm as f: @@ -1294,7 +1294,7 @@ def from_file( if isinstance(f, str): if filename is None: filename = f - cm = open(f) + cm: contextlib.AbstractContextManager = open(f) else: cm = contextlib.nullcontext(f) with cm as f: