]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
more ty fixes
authorBob Halley <halley@dnspython.org>
Sat, 6 Dec 2025 22:46:42 +0000 (14:46 -0800)
committerBob Halley <halley@dnspython.org>
Sat, 6 Dec 2025 22:46:42 +0000 (14:46 -0800)
dns/asyncquery.py
dns/name.py
dns/query.py
dns/zone.py

index b5e58540376190bce56d3c554b9f22be67c95ee7..36905a2091a7439b03b09852f20953f9d7ccab68 100644 (file)
@@ -731,10 +731,10 @@ async def _http3(
     wire = q.to_wire()
     the_connection: dns.quic.AsyncQuicConnection
     if connection:
-        cfactory = dns.quic.null_factory
-        mfactory = dns.quic.null_factory
+        cfactory = dns.quic.null_factory  # type: ignore
+        mfactory = dns.quic.null_factory  # type: ignore
     else:
-        (cfactory, mfactory) = dns.quic.factories_for_backend(backend)
+        (cfactory, mfactory) = dns.quic.factories_for_backend(backend)  # type: ignore
 
     async with cfactory() as context:
         async with mfactory(
@@ -802,11 +802,11 @@ async def quic(
     wire = q.to_wire()
     the_connection: dns.quic.AsyncQuicConnection
     if connection:
-        cfactory = dns.quic.null_factory
-        mfactory = dns.quic.null_factory
+        cfactory = dns.quic.null_factory  # type: ignore
+        mfactory = dns.quic.null_factory  # type: ignore
         the_connection = connection
     else:
-        (cfactory, mfactory) = dns.quic.factories_for_backend(backend)
+        (cfactory, mfactory) = dns.quic.factories_for_backend(backend)  # type: ignore
 
     async with cfactory() as context:
         async with mfactory(
index 45c8f454ecc8b5386393a3e5f9b94d3604801c89..5af5583912d5fd340802bd15010878982f0495c7 100644 (file)
@@ -764,9 +764,9 @@ class Name:
 
         l = len(self.labels)
         if depth == 0:
-            return (self, dns.name.empty)
+            return (self, empty)
         elif depth == l:
-            return (dns.name.empty, self)
+            return (empty, self)
         elif depth < 0 or depth > l:
             raise ValueError("depth must be >= 0 and <= the length of the name")
         return (Name(self[:-depth]), Name(self[-depth:]))
@@ -1228,8 +1228,8 @@ def _absolute_successor(name: Name, origin: Name, prefix_ok: bool) -> Name:
             new_labels = [least_significant_label + _MINIMAL_OCTET]
             new_labels.extend(name.labels[1:])
             try:
-                return dns.name.Name(new_labels)
-            except dns.name.NameTooLong:
+                return Name(new_labels)
+            except NameTooLong:
                 pass
         # We can't extend the label either, so we'll try to increment the least
         # signficant non-maximal byte in it.
index 9baa0ad81719b2b2975b991e3c14fd409e7c56db..64a2e2d7d828be85dc4be3607d8f7cd738296c9e 100644 (file)
@@ -699,11 +699,11 @@ def _http3(
     q.id = 0
     wire = q.to_wire()
     the_connection: dns.quic.SyncQuicConnection
-    the_manager: dns.quic.SyncQuicManager
+    the_manager: dns.quic.SyncQuicManager  # type: ignore
     if connection:
         manager: contextlib.AbstractContextManager = contextlib.nullcontext(None)
     else:
-        manager = dns.quic.SyncQuicManager(
+        manager = dns.quic.SyncQuicManager(  # type: ignore
             verify_mode=verify, server_name=hostname, h3=True  # type: ignore
         )
         the_manager = manager  # for type checking happiness
@@ -1494,12 +1494,12 @@ def quic(
     q.id = 0
     wire = q.to_wire()
     the_connection: dns.quic.SyncQuicConnection
-    the_manager: dns.quic.SyncQuicManager
+    the_manager: dns.quic.SyncQuicManager # type: ignore
     if connection:
         manager: contextlib.AbstractContextManager = contextlib.nullcontext(None)
         the_connection = connection
     else:
-        manager = dns.quic.SyncQuicManager(
+        manager = dns.quic.SyncQuicManager(  # type: ignore
             verify_mode=verify, server_name=hostname  # type: ignore
         )
         the_manager = manager  # for type checking happiness
index f68e8e85b93a2e7db6bbbbe86c17b0a0a8814abe..b71f244d17c23c1d9de8fc9d785182efb0143eaf 100644 (file)
@@ -626,7 +626,7 @@ class Zone(dns.transaction.TransactionManager):
         f: Any,
         sorted: bool = True,
         relativize: bool = True,
-        nl: str | None = None,
+        nl: str | bytes | None = None,
         want_comments: bool = False,
         want_origin: bool = False,
     ) -> None:
@@ -644,7 +644,7 @@ class Zone(dns.transaction.TransactionManager):
         names in the output will be relativized to the zone's origin
         if possible.
 
-        *nl*, a ``str`` or None.  The end of line string.  If not
+        *nl*, a ``str``, ``bytes``, or None.  The end of line string.  If not
         ``None``, the output will use the platform's native
         end-of-line marker (i.e. LF on POSIX, CRLF on Windows).
 
@@ -662,6 +662,7 @@ class Zone(dns.transaction.TransactionManager):
         else:
             cm = contextlib.nullcontext(f)
         with cm as f:
+            assert f is not None
             # must be in this way, f.encoding may contain None, or even
             # attribute may not be there
             file_enc = getattr(f, "encoding", None)