diff --git a/pyproject.toml b/pyproject.toml index a226775..8439925 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,43 +31,23 @@ skip_gitignore = true [tool.ruff] -select = [ - "A", # flake8-builtins - "ANN", # flake8-annotations - "ARG", # flake8-unused-arguments - "B", # flake8-bugbear - "BLE", # flake8-blind-except - "C4", # flake8-comprehensions - "C90", # mccabe - "DTZ", # flake8-datetimez - "E", # pycodestyle - "EM", # flake8-errmsg - "ERA", # eradicate - "F", # pyflakes - # "FBT", # flake8-boolean-trap - "ICN", # flake8-import-conventions - "ISC", # flake8-implicit-str-concat - "N", # pep8-naming - "PIE", # flake8-pie - "PGH", # pygrep-hooks - "PLC", # pylint - "PLE", # pylint - "PLR", # pylint - "PLW", # pylint - "Q", # flake8-quotes - "RUF", # Ruff-specific rules - "RET", # flake8-return - "S", # flake8-bandit - "SIM", # flake8-simplify - "T", # flake8-debugger, flake8-print - "TID", # flake8-tidy-imports - "UP", # pyupgrade - "W", # pycodestyle - "YTT", # flake8-2020 -] +select = ["ALL"] ignore = [ "ANN101", # missing-type-self + "COM812", # missing-trailing-comma + "D100", # undocumented-public-module + "D104", # undocumented-public-package + "D203", # one-blank-line-before-class + "D205", # blank-line-after-summary + "D212", # multi-line-summary-first-line + "D213", # multi-line-summary-second-line + "D400", # ends-in-period + "D401", # non-imperative-mood + "D404", # docstring-starts-with-this + "D415", # ends-in-punctuation + "I001", # unsorted-imports + "PTH123", # builtin-open ] target-version = "py311" diff --git a/tools/common.py b/tools/common.py index 72ea8aa..edd43cd 100644 --- a/tools/common.py +++ b/tools/common.py @@ -4,7 +4,6 @@ import json import logging -import os import shutil from http import HTTPStatus from pathlib import Path @@ -37,8 +36,8 @@ def download_file(url: str, path: Path) -> bool: """ try: file_response = requests.get(url, timeout=5) - except (ConnectTimeout, ReadTimeout) as err: - log.error("Error while trying to download from %s, %s", url, err) + except (ConnectTimeout, ReadTimeout): + log.exception("Error while trying to download from %s", url) return False if not HTTPStatus.OK >= file_response.status_code < HTTPStatus.BAD_REQUEST: @@ -61,10 +60,8 @@ def download_file(url: str, path: Path) -> bool: def initialize_directory(path: Path) -> None: - """ - Remove path (if it exists) and containing files, then recreate path - """ + """Remove path (if it exists) and containing files, then recreate path""" if path.exists() and path.is_dir(): shutil.rmtree(path) - os.mkdir(path) + path.mkdir() diff --git a/tools/prepare.py b/tools/prepare.py index 1fa2e08..a4df64f 100644 --- a/tools/prepare.py +++ b/tools/prepare.py @@ -2,9 +2,6 @@ # # SPDX-License-Identifier: AGPL-3.0-or-later -""" -Download / prepare / process XMPP Providers data -""" import json import logging import os @@ -55,9 +52,7 @@ def prepare_provider_data_files() -> None: - """ - Download and prepare provider data files - """ + """Download and prepare provider data files""" initialize_directory(DOWNLOAD_PATH) # Temporarily move 'logo' folder and 'recommended_clients.json' @@ -180,9 +175,7 @@ def _get_providers_file() -> None: def create_provider_pages() -> None: - """ - Create a .md page per provider - """ + """Create a .md page per provider""" log.info("Creating provider pages") initialize_directory(PROVIDERS_PAGES_PATH) @@ -218,9 +211,7 @@ def _parse_doap_infos(doap_file: str) -> dict[str, list[str]] | None: def prepare_client_data_file() -> None: - """ - Download and prepare clients data - """ + """Download and prepare clients data""" log.info("Downloading clients list file") Path(DOWNLOAD_PATH / "clients_data/doap_files").mkdir(parents=True) @@ -248,16 +239,13 @@ def prepare_client_data_file() -> None: xsf_software_list = json.load(json_file) log.info("Parsing clients list infos") - client_names: list[str] = [] - for client in providers_clients_list: - client_names.append(client) client_infos: list[dict[str, str | bool | list[str] | None]] = [] for package in xsf_software_list: if "client" not in package["categories"]: continue - if package["name"] in client_names: + if package["name"] in providers_clients_list: provider_infos = providers_clients_list[package["name"]] if package["doap"] is not None: log.info("Downloading DOAP file for: %s", package["name"]) diff --git a/tools/run.py b/tools/run.py index 0659c32..05ed936 100644 --- a/tools/run.py +++ b/tools/run.py @@ -17,6 +17,7 @@ class ToolsArgumentParser(ArgumentParser): """Parses arguments for XMPP Providers Website processor.""" def __init__(self) -> None: + """Parses arguments for XMPP Providers Website processor.""" super().__init__() self.description = """ diff --git a/tools/statistics.py b/tools/statistics.py index 997ba16..b66b483 100644 --- a/tools/statistics.py +++ b/tools/statistics.py @@ -14,18 +14,19 @@ def prepare_statistics() -> None: # noqa: C901, PLR0912, PLR0915 + """Create statistics dict which can be consumed by echarts.""" try: with open(DATA_PATH / "providers.json") as file: providers_data = json.load(file) - except json.decoder.JSONDecodeError as e: - log.error("Could not open providers.json: %s", e) + except json.decoder.JSONDecodeError: + log.exception("Could not open providers.json") return try: with open(DATA_PATH / "filtered_providers.json") as file: filtered_providers_data = json.load(file) - except json.decoder.JSONDecodeError as e: - log.error("Could not open filtered_providers.json: %s", e) + except json.decoder.JSONDecodeError: + log.exception("Could not open filtered_providers.json") return statistics_data = {