From d25c46de1d1b9af1401a9824218b85acfc16ca3e Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Tue, 23 Jul 2024 14:46:18 +0200 Subject: [PATCH] reformat examples (#1107) --- examples/async_dns.py | 2 +- examples/ddns.py | 2 +- examples/ddr.py | 4 ++-- examples/doh-json.py | 3 ++- examples/query_specific.py | 2 +- examples/receive_notify.py | 5 ++--- examples/reverse.py | 5 +++-- examples/send_notify.py | 2 +- examples/tsig.py | 12 ++++++------ examples/zonediff.py | 4 ++-- 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/examples/async_dns.py b/examples/async_dns.py index 297afcb0..e531c1d9 100644 --- a/examples/async_dns.py +++ b/examples/async_dns.py @@ -2,9 +2,9 @@ import sys import trio -import dns.message import dns.asyncquery import dns.asyncresolver +import dns.message async def main(): diff --git a/examples/ddns.py b/examples/ddns.py index 154ab3da..d4d89a03 100755 --- a/examples/ddns.py +++ b/examples/ddns.py @@ -27,9 +27,9 @@ import sys -import dns.update import dns.query import dns.tsigkeyring +import dns.update # # Replace the keyname and secret with appropriate values for your diff --git a/examples/ddr.py b/examples/ddr.py index a8ecd9ad..fd7ca601 100644 --- a/examples/ddr.py +++ b/examples/ddr.py @@ -22,10 +22,10 @@ print(res.nameservers) import asyncio -# import trio - import dns.asyncresolver +# import trio + async def amain(): res = dns.asyncresolver.Resolver(configure=False) diff --git a/examples/doh-json.py b/examples/doh-json.py index c8d830ba..bad85bb9 100755 --- a/examples/doh-json.py +++ b/examples/doh-json.py @@ -2,13 +2,14 @@ import copy import json + import httpx import dns.flags import dns.message -import dns.resolver import dns.rdataclass import dns.rdatatype +import dns.resolver # This shows how to convert to/from dnspython's message object and the # DNS-over-HTTPS (DoH) JSON form used by Google and Cloudflare, and diff --git a/examples/query_specific.py b/examples/query_specific.py index 2f13b240..7396021a 100644 --- a/examples/query_specific.py +++ b/examples/query_specific.py @@ -3,9 +3,9 @@ # Two ways of querying a specific nameserver. import dns.message +import dns.query import dns.rdataclass import dns.rdatatype -import dns.query # This way is just like nslookup/dig: diff --git a/examples/receive_notify.py b/examples/receive_notify.py index 97d01f30..0ffb9430 100644 --- a/examples/receive_notify.py +++ b/examples/receive_notify.py @@ -4,14 +4,13 @@ # really was a NOTIFY, and otherwise handle errors. import socket +from typing import cast import dns.flags import dns.message +import dns.name import dns.rdataclass import dns.rdatatype -import dns.name - -from typing import cast address = "127.0.0.1" port = 53535 diff --git a/examples/reverse.py b/examples/reverse.py index 012617c2..a6dc1588 100755 --- a/examples/reverse.py +++ b/examples/reverse.py @@ -16,12 +16,13 @@ # If this weren't a demo script, there'd be a way of specifying the # origin for each zone instead of constructing it from the filename. -import dns.zone -import dns.ipv4 import os.path import sys from typing import Dict, List # pylint: disable=unused-import +import dns.ipv4 +import dns.zone + reverse_map = {} # type: Dict[str, List[str]] for filename in sys.argv[1:]: diff --git a/examples/send_notify.py b/examples/send_notify.py index 08a0894c..9cbdb664 100755 --- a/examples/send_notify.py +++ b/examples/send_notify.py @@ -12,9 +12,9 @@ import dns.message import dns.name import dns.opcode import dns.query -import dns.rrset import dns.rdataclass import dns.rdatatype +import dns.rrset def main(): diff --git a/examples/tsig.py b/examples/tsig.py index 3487ec9f..d8d02154 100644 --- a/examples/tsig.py +++ b/examples/tsig.py @@ -4,15 +4,15 @@ import dns.message import dns.query import dns.tsig - -key = dns.tsig.Key("keyname.", "bnp6+y85UcBfsieuB/Uhx3EUsjc8wAFyyCSS5rhScb0=", - algorithm=dns.tsig.HMAC_SHA256) +key = dns.tsig.Key( + "keyname.", + "bnp6+y85UcBfsieuB/Uhx3EUsjc8wAFyyCSS5rhScb0=", + algorithm=dns.tsig.HMAC_SHA256, +) q = dns.message.make_query("example.", "SOA") q.use_tsig(keyring=key) -r = dns.query.udp(q, "127.0.0.1") # your authority address here +r = dns.query.udp(q, "127.0.0.1") # your authority address here soa = r.find_rrset(r.answer, "example", "IN", "SOA") print(soa) - - diff --git a/examples/zonediff.py b/examples/zonediff.py index 2957f87e..11aa19e4 100755 --- a/examples/zonediff.py +++ b/examples/zonediff.py @@ -21,13 +21,13 @@ # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """See diff_zones.__doc__ for more information""" -from typing import cast, Union, Any # pylint: disable=unused-import +from typing import Any, Union, cast # pylint: disable=unused-import __all__ = ["diff_zones", "format_changes_plain", "format_changes_html"] try: - import dns.zone import dns.node + import dns.zone except ImportError: raise SystemExit("Please install dnspython") -- 2.47.3