From 195beed6ee3e4e7737c41484ced7a2772f7077c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Zaj=C4=85c?= Date: Tue, 26 Dec 2023 08:33:16 +0100 Subject: [PATCH] lint --- .mypy.ini | 3 +++ common/config.py | 22 ++++++++++++---------- docs/conf.py | 3 ++- setup.cfg | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.mypy.ini b/.mypy.ini index c2d0fb0..d44f145 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -4,6 +4,9 @@ ignore_missing_imports = True [mypy-dkim.*] ignore_missing_imports = True +[mypy-sphinx_rtd_theme.*] +ignore_missing_imports = True + [mypy-jinja2_simple_tags.*] ignore_missing_imports = True diff --git a/common/config.py b/common/config.py index 4da409a..620fb58 100644 --- a/common/config.py +++ b/common/config.py @@ -1,9 +1,9 @@ from typing import Annotated, Any, List, get_type_hints -from common.language import Language - import decouple +from common.language import Language + DEFAULTS = {} @@ -20,12 +20,12 @@ class Data: "The URL used to connect to the database (as documented on " "https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls). The CERT PL " "production instance uses PostgreSQL - this is the database the system has been most " - "thoroughly tested on." + "thoroughly tested on.", ] = get_config("DB_URL", default=None) REDIS_MESSAGE_DATA_EXPIRY_SECONDS: Annotated[ int, "The data in Redis expires in order to make sure Redis never takes too much " - "memory - the full scan logs are stored in a Postgres database." + "memory - the full scan logs are stored in a Postgres database.", ] = get_config("REDIS_MESSAGE_DATA_EXPIRY_SECONDS", cast=int, default=10 * 24 * 60 * 60) REDIS_URL: Annotated[ str, @@ -40,33 +40,35 @@ class Network: List[str], "A comma-separated list of nameservers that will be used to resolve domains. If you want " "to provide custom ones, remember to modify the ones used by Docker. At CERT PL we use a " - "separate `docker-compose.yml` file with additional configuration specific to our instance." + "separate `docker-compose.yml` file with additional configuration specific to our instance.", ] = get_config("NAMESERVERS", default="8.8.8.8", cast=decouple.Csv(str)) SSL_PRIVATE_KEY_PATH: Annotated[ str, "SSL private key path. Remember:\n" " 1. to mount it into your Docker container,\n" " 2. to restart the containers if a new one is generated,\n" - " 2. that autogenerated certificate files may be symbolic links - the destination directory must also be mounted." + " 2. that autogenerated certificate files may be symbolic links - the destination directory must also be mounted.", ] = decouple.config("SSL_PRIVATE_KEY_PATH", default=None) - SSL_CERTIFICATE_PATH: Annotated[str, "SSL certificate path."] = decouple.config("SSL_PRIVATE_KEY_PATH", default=None) + SSL_CERTIFICATE_PATH: Annotated[str, "SSL certificate path."] = decouple.config( + "SSL_PRIVATE_KEY_PATH", default=None + ) class UI: LANGUAGE: Annotated[ str, "The language the site will use (in the form of language_COUNTRY, e.g. en_US). " - f"Supported options are: {', '.join(sorted(language.value for language in Language))}." + f"Supported options are: {', '.join(sorted(language.value for language in Language))}.", ] = get_config("LANGUAGE", default="en_US") OLD_CHECK_RESULTS_AGE_MINUTES: Annotated[ int, "If the user is viewing old check results, they will see a message that the check result " "may not describe the current configuration. This is the threshold (in minutes) how old " - "the check results need to be for that message to be displayed." + "the check results need to be for that message to be displayed.", ] = get_config("OLD_CHECK_RESULTS_AGE_MINUTES", default=60, cast=int) SITE_CONTACT_EMAIL: Annotated[ str, "The contact e-mail that will be displayed in the UI (currently in the message that " - "describes what to do if e-mails to the system aren't received)." + "describes what to do if e-mails to the system aren't received).", ] = get_config("SITE_CONTACT_EMAIL", default=None) @staticmethod diff --git a/docs/conf.py b/docs/conf.py index 7d6bf9f..67d1e6a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,6 +9,7 @@ import datetime import os import sys +from typing import List # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -69,7 +70,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [] +html_static_path: List[str] = [] html_css_files = [ diff --git a/setup.cfg b/setup.cfg index dc12d45..91bc837 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,4 @@ [flake8] # whitespace before :, too long line, line break before binary operator ignore = E203,E501,W503 -exclude = .venv.translations +exclude = .venv.translations,docs/venv