diff --git a/nyacme/__main__.py b/nyacme/__main__.py index b2662af..4a20467 100644 --- a/nyacme/__main__.py +++ b/nyacme/__main__.py @@ -11,7 +11,7 @@ from .config import read_config logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(name)s: %(message)s') log = logging.getLogger('nyacme') - + def main() -> None: parser = argparse.ArgumentParser( prog='nyacme', @@ -36,7 +36,7 @@ def main() -> None: cert_path = output_dir / domain / 'cert.pem' if cert_path.is_file(): - cmd = [ 'openssl', 'x509', '-enddate', '-noout', '-in', cert_path ] + cmd: list[str] = [ 'openssl', 'x509', '-enddate', '-noout', '-in', str(cert_path) ] out = subprocess.run(cmd, stdout=subprocess.PIPE, check=True).stdout.decode('utf-8').strip() date = datetime.strptime(out, 'notAfter=%b %d %H:%M:%S %Y %Z') # if more than 1 month, skip @@ -86,8 +86,8 @@ def main() -> None: all_key.hardlink_to(domain_key) if acquired: - for cmd in config.post_acquire: - subprocess.run(cmd, shell=True, check=True) + for post_cmd in config.post_acquire: + subprocess.run(post_cmd, shell=True, check=True) if __name__ == '__main__': main() diff --git a/nyacme/handlers/porkbun.py b/nyacme/handlers/porkbun.py index afe1cd9..a7c26fa 100644 --- a/nyacme/handlers/porkbun.py +++ b/nyacme/handlers/porkbun.py @@ -1,6 +1,6 @@ import json import urllib.request -from typing import Any, Optional +from typing import Any from ..config import Config from .base import Handler @@ -17,10 +17,8 @@ class PorkbunHandler(Handler): self.nameservers = self.fetch(f'/domain/getNs/{self.zone}')['ns'] - def fetch(self, url: str, data: Optional[dict[str, Any]] = None) -> Any: + def fetch(self, url: str, data: dict[str, Any] = {}) -> Any: req = urllib.request.Request('https://api.porkbun.com/api/json/v3' + url) - if not data: - data = {} data['apikey'] = self.apikey data['secretapikey'] = self.secretapikey diff --git a/nyacme/hook.py b/nyacme/hook.py index ef7fbda..d25cafb 100644 --- a/nyacme/hook.py +++ b/nyacme/hook.py @@ -20,7 +20,7 @@ handlers = { } class Args: - def __init__(self, argv): + def __init__(self, argv: list[str]) -> None: # one of 'begin', 'done', 'failed' self.method = argv[1] # challenge type (dns-01, http-01 or tls-alpn-01)