*: Fix all typing hint related errors

- Try to mark class variables in component classes.

- Leave typing hints generic, such as 'list' and 'dict' where content is usually
not filled, too complex, or context is unimportant.

- backups: Handle failure for tarfile extraction so that methods are not called
on potentially None valued variables.

- backups: Prevent potentially passing a keyword argument twice.

- dynamicdns: Deal properly with outcome of urlparsing.

- ejabberd: Deal with failed regex match

- email: Fix a mypy compliant when iterating a filtered list.

- tor: Don't reuse variables for different typed values.

- tor: Don't reuse variables for different typed values.

- operation: Return None explicitly.

- operation: Ensure that keyword argument is not repeated.

Tests:

- Where only typing hints were modified and no syntax error came up, additional
testing was not done.

- `mypy --ignore-missing-imports .` run successfully.

- Generate developer documentation.

- Service runs without errors upon start up.

- backups: Listing and restoring specific apps from a backup works.

- backups: Mounting a remote backup repository works.

- NOT TESTED: dynamicdns: Migrating from old style configuration works.

- ejabberd: Verify that setting coturn configuration works.

- email: Test that showing configuration from postfix works.

- tor: Orport value is properly shown.

- transmission: Configuration values are properly set.

- users: Running unit tests as root works.

- operation: Operation status messages are show properly during app install.

- ./setup.py install runs

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2023-09-25 20:03:24 -04:00
1 parent a709f3a6a8
commit 2dd00a8f08
43 files changed
+111 -87

No files matched your search

+7 -8
View File
@@ -2,8 +2,6 @@
"""App component for other apps to manage their STUN/TURN server configuration.
"""
from __future__ import annotations # Can be removed in Python 3.10
import base64
import hashlib
import hmac
@@ -11,6 +9,7 @@ import json
import re
from dataclasses import dataclass, field
from time import time
from typing import ClassVar, Iterable
from plinth import app
@@ -36,9 +35,9 @@ class TurnConfiguration:
that must be used by a STUN/TURN client after advice from the server.
"""
domain: str = None
domain: str | None = None
uris: list[str] = field(default_factory=list)
shared_secret: str = None
shared_secret: str | None = None
def __post_init__(self):
"""Generate URIs after object initialization if necessary."""
@@ -76,8 +75,8 @@ class UserTurnConfiguration(TurnConfiguration):
time.
"""
username: str = None
credential: str = None
username: str | None = None
credential: str | None = None
def to_json(self) -> str:
"""Return a JSON representation of the configuration."""
@@ -102,7 +101,7 @@ class TurnConsumer(app.FollowerComponent):
"""
_all = {}
_all: ClassVar[dict[str, 'TurnConsumer']] = {}
def __init__(self, component_id):
"""Initialize the component.
@@ -115,7 +114,7 @@ class TurnConsumer(app.FollowerComponent):
self._all[component_id] = self
@classmethod
def list(cls) -> list[TurnConsumer]: # noqa
def list(cls) -> Iterable['TurnConsumer']:
"""Return a list of all Coturn components."""
return cls._all.values()