From b69f3386170802f3988009fbf9f3edd05785903d Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sun, 3 May 2020 06:59:34 -0700 Subject: [PATCH] more things to make mypy happier --- dns/dnssec.py | 4 ++-- dns/exception.pyi | 1 + dns/inet.py | 2 +- dns/name.py | 10 +++------- dns/query.py | 2 +- dns/resolver.py | 8 ++++---- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/dns/dnssec.py b/dns/dnssec.py index 8e3621a2..171a55da 100644 --- a/dns/dnssec.py +++ b/dns/dnssec.py @@ -589,6 +589,6 @@ except ImportError: validate_rrsig = _need_pyca _have_pyca = False else: - validate = _validate - validate_rrsig = _validate_rrsig + validate = _validate # type: ignore + validate_rrsig = _validate_rrsig # type: ignore _have_pyca = True diff --git a/dns/exception.pyi b/dns/exception.pyi index 4b346cc4..b29bfbea 100644 --- a/dns/exception.pyi +++ b/dns/exception.pyi @@ -3,6 +3,7 @@ from typing import Set, Optional, Dict class DNSException(Exception): supp_kwargs : Set[str] kwargs : Optional[Dict] + fmt : Optional[str] class SyntaxError(DNSException): ... class FormError(DNSException): ... diff --git a/dns/inet.py b/dns/inet.py index e7729f2f..d7d50056 100644 --- a/dns/inet.py +++ b/dns/inet.py @@ -33,7 +33,7 @@ AF_INET = socket.AF_INET try: AF_INET6 = socket.AF_INET6 except AttributeError: - AF_INET6 = 9999 + AF_INET6 = 9999 # type: ignore def inet_pton(family, text): diff --git a/dns/name.py b/dns/name.py index 72d2852f..4fb067cf 100644 --- a/dns/name.py +++ b/dns/name.py @@ -23,9 +23,9 @@ import io import struct import sys -import encodings.idna +import encodings.idna # type: ignore try: - import idna + import idna # type: ignore have_idna_2008 = True except ImportError: have_idna_2008 = False @@ -33,11 +33,7 @@ except ImportError: import dns.exception import dns.wiredata -try: - maxint = sys.maxint # pylint: disable=sys-max-int -except AttributeError: - maxint = (1 << (8 * struct.calcsize("P"))) // 2 - 1 - +maxint = sys.maxsize # fullcompare() result values diff --git a/dns/query.py b/dns/query.py index 15293774..b995003f 100644 --- a/dns/query.py +++ b/dns/query.py @@ -49,7 +49,7 @@ except ImportError: try: import ssl except ImportError: - class ssl(object): + class ssl(object): # type: ignore class WantReadException(Exception): pass class WantWriteException(Exception): diff --git a/dns/resolver.py b/dns/resolver.py index 805c5bd5..bc865633 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -25,7 +25,7 @@ import random try: import threading as _threading except ImportError: - import dummy_threading as _threading + import dummy_threading as _threading # type: ignore import dns.exception import dns.flags @@ -991,10 +991,10 @@ class Resolver(object): port_answered = port rcode = response.rcode() if rcode == dns.rcode.YXDOMAIN: - ex = YXDOMAIN() - errors.append((nameserver, tcp_attempt, port, ex, + yex = YXDOMAIN() + errors.append((nameserver, tcp_attempt, port, yex, response)) - raise ex + raise yex if rcode == dns.rcode.NOERROR or \ rcode == dns.rcode.NXDOMAIN: break -- 2.47.3