chore: improve type annotations

This commit is contained in:
ptrcnull 2024-07-27 16:15:57 +02:00
parent 52fa7292aa
commit 5fad1f8ebe
3 changed files with 7 additions and 9 deletions

View file

@ -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()

View file

@ -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

View file

@ -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)