From fe551749af05a1ac3cb09a4640aa6c9cc8556212 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 8 Nov 2014 23:20:34 +0100 Subject: [PATCH] experiment with mypy type annotations --- zonemaker/zone.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zonemaker/zone.py b/zonemaker/zone.py index 435b039..f5db2a8 100644 --- a/zonemaker/zone.py +++ b/zonemaker/zone.py @@ -1,3 +1,4 @@ +from typing import List, Dict, Any import ipaddress, re second = 1 @@ -5,7 +6,7 @@ minute = 60*second hour = 60*minute day = 24*hour -def hostname(name): +def hostname(name: str) -> str: # check hostname for validity label = r'[a-zA-Z90-9]([a-zA-Z90-9-]{0,61}[a-zA-Z90-9])?' # must not start or end with hyphen pattern = r'^{0}(\.{0})*\.?'.format(label) @@ -43,10 +44,10 @@ class Delegation(): pass class Zone: - def __init__(self, name, mail, NS, - secondary_refresh, secondary_retry, secondary_discard, - NX_TTL = None, A_TTL = None, other_TTL = None, - domains = []): + def __init__(self, name: str, mail: str, NS: List[str], + secondary_refresh: int, secondary_retry: int, secondary_discard: int, + NX_TTL: int = None, A_TTL: int = None, other_TTL: int = None, + domains: Dict[str, Any] = {}) -> None: self._name = hostname(name) if not mail.endswith('.'): raise Exception("Mail must be absolute, end with a dot") atpos = mail.find('@') -- 2.30.2