Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/431.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make `sydent.config` pass `mypy --strict`.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ strict = true
files = [
# Find files that pass with
# find sydent tests -type d -not -name __pycache__ -exec bash -c "mypy --strict '{}' > /dev/null" \; -print
"sydent/config",
"sydent/db",
"sydent/users",
"sydent/util",
Expand Down
5 changes: 2 additions & 3 deletions sydent/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import copy
import logging
import logging.handlers
import os
from configparser import DEFAULTSECT, ConfigParser
Expand Down Expand Up @@ -163,7 +162,7 @@ class SydentConfig:
Sydent object that uses it.
"""

def __init__(self):
def __init__(self) -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? (Does strict require this?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed if there are no arguments other than self. Some discussion here: matrix-org/synapse#10892 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this is from the option disallow-untyped-defswhich is implied by--strict`.

self.general = GeneralConfig()
self.database = DatabaseConfig()
self.crypto = CryptoConfig()
Expand Down Expand Up @@ -243,7 +242,7 @@ def parse_config_file(self, config_file: str) -> None:
cfg.write(fp)
fp.close()

def parse_config_dict(self, config_dict: Dict) -> None:
def parse_config_dict(self, config_dict: Dict[str, Dict[str, str]]) -> None:
"""
Parse the given config from a dictionary, populating missing items and sections

Expand Down
2 changes: 1 addition & 1 deletion sydent/config/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def list_from_comma_sep_string(rawstr: str) -> List[str]:
return [x.strip() for x in rawstr.split(",")]


def parse_cfg_bool(value: str):
def parse_cfg_bool(value: str) -> bool:
"""
Parse a string config option into a boolean
This method ignores capitalisation
Expand Down