]> mj.ucw.cz Git - pynsc.git/commitdiff
Fix typing problems
authorMartin Mareš <mj@ucw.cz>
Sat, 22 Nov 2025 17:25:05 +0000 (18:25 +0100)
committerMartin Mareš <mj@ucw.cz>
Sat, 22 Nov 2025 17:25:05 +0000 (18:25 +0100)
nsconfig/core.py
nsconfig/util.py

index 3e6e4d5f66ad960a7a045d673103ae8b5c7e3a66..0c76eb5d3f28fa4f6479b0da0ab1ad4a122d3bad 100644 (file)
@@ -6,6 +6,7 @@ from datetime import datetime, timedelta
 import dns.name
 from dns.name import Name
 from dns.node import Node
+import dns.rdata
 from dns.rdata import Rdata
 from dns.rdataclass import RdataClass
 from dns.rdatatype import RdataType
@@ -280,7 +281,7 @@ class NscZonePrimary(NscZone):
 
         self.aliases = []
 
-        self.zone = dns.zone.Zone(origin=self.name, rdclass=RdataClass.IN)
+        self.zone = Zone(origin=self.name, rdclass=RdataClass.IN)
         self.update_soa()
 
     @property
@@ -322,6 +323,7 @@ class NscZonePrimary(NscZone):
     def dump(self, file: Optional[TextIO] = None) -> None:
         # Could use self.zone.to_file(sys.stdout), but we want better formatting
         file = file or sys.stdout
+        assert file is not None
         file.write(self.zone_header())
         file.write(f'$TTL\t\t{self.config.default_ttl}\n\n')
         last_name = None
@@ -414,6 +416,7 @@ class NscZonePrimary(NscZone):
             rds_aaaa = node.get_rdataset(RdataClass.IN, RdataType.AAAA)
             if rds_a or rds_aaaa:
                 mx_rds = node.get_rdataset(RdataClass.IN, RdataType.MX, create=True)
+                assert mx_rds is not None
                 if not mx_rds:
                     mx_rds.add(
                         dns.rdtypes.ANY.MX.MX(RdataClass.IN, RdataType.MX, 0, dns.name.root),
@@ -425,7 +428,7 @@ class NscZoneSecondary(NscZone):
     primary_server: IPAddress
     secondary_file: Path
 
-    def __init__(self, *args, primary_server=IPAddress, **kwargs) -> None:
+    def __init__(self, *args, primary_serverIPAddress, **kwargs) -> None:
         super().__init__(*args, **kwargs)
         self.zone_type = ZoneType.secondary
         self.primary_server = primary_server
@@ -435,7 +438,7 @@ class NscZoneSecondary(NscZone):
 class NscZoneAlias(NscZone):
     alias_for: NscZonePrimary
 
-    def __init__(self, *args, alias_for=NscZonePrimary, **kwargs) -> None:
+    def __init__(self, *args, alias_forNscZonePrimary, **kwargs) -> None:
         assert isinstance(alias_for, NscZonePrimary)
         super().__init__(*args, **kwargs)
         self.zone_type = ZoneType.alias
@@ -491,7 +494,7 @@ class Nsc:
                  alias_for: Optional[NscZonePrimary] = None,
                  secondary_to: str | IPAddress | None = None,
                  inherit_config: Optional[NscZoneConfig] = None,
-                 **kwargs) -> Zone:
+                 **kwargs) -> NscZone:
         if inherit_config is None:
             inherit_config = self.default_zone_config
 
index bcff99c18a6524ee22d6afa4229359e0874384df..6ebe0ae3d398c38da2f1065c0bcfe2b2c7d1ed23 100644 (file)
@@ -6,7 +6,7 @@ from dns.name import Name
 from enum import Enum, auto
 from ipaddress import ip_address, IPv4Address, IPv6Address, ip_network, IPv4Network, IPv6Network
 from datetime import timedelta
-from typing import Any, List, Optional
+from typing import Any, List
 
 
 IPAddress = IPv4Address | IPv6Address