aboutsummaryrefslogtreecommitdiff
path: root/mu4web/maildir.py
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-05-02 03:00:59 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-05-02 03:00:59 +0200
commitd17967eea2e42466103347257002451f17b5d5e8 (patch)
treed299b451ade590ab3cbf90c703c5914cad2fef4e /mu4web/maildir.py
parentHopefully fix installation issues. (diff)
downloadmu4web-d17967eea2e42466103347257002451f17b5d5e8.tar.gz
mu4web-d17967eea2e42466103347257002451f17b5d5e8.tar.xz
Configure linters.
Introduce flake8 and mypy for better error checking. Fix all errors and warnings emitted by those. Also fix type error with `url_for`.
Diffstat (limited to 'mu4web/maildir.py')
-rw-r--r--mu4web/maildir.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/mu4web/maildir.py b/mu4web/maildir.py
index c2abc16..dd5be1c 100644
--- a/mu4web/maildir.py
+++ b/mu4web/maildir.py
@@ -6,6 +6,8 @@ from .util import find
from urllib.parse import urlencode
+from pathlib import Path
+
from typing import (
Union
)
@@ -47,7 +49,7 @@ def _build_tree(items: list[list[str]]) -> MaildirGroup:
return node
-def find_maildirs(basedir) -> MaildirGroup:
+def find_maildirs(basedir: str) -> MaildirGroup:
"""
Find all maildirs located under basedir.
@@ -59,7 +61,7 @@ def find_maildirs(basedir) -> MaildirGroup:
and a group of maildirs then it will have two separate entries.
"""
basedir = basedir.rstrip('/')
- files = find(basedir, type='d', name='cur')
+ files = find(Path(basedir), type='d', name='cur')
# + 1 removes leading slash
# - 4 removes '/cur'
dirs = [entry[len(basedir) + 1:-4].decode('UTF-8').split(os.path.sep)
@@ -72,6 +74,7 @@ def serialize_maildir(maildir: MaildirGroup, path: list[str] = []) -> HTML:
"""Build a (recursive) list from a maildir node."""
entries: list[HTML] = []
for node in natsorted(maildir.children, key=lambda n: n.name):
+ entry: HTML
if isinstance(node, MaildirEntry):
parts = '/'.join(path + [node.name])
url = 'search?' + urlencode({'q': f'maildir:"/{parts}"'})