From 76de3b6f9c73b74620a2ff4fb0804ef5c527dc5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 22 Dec 2025 11:50:36 +0100 Subject: [PATCH] chore: lint long lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Timothée Mazzucotelli --- .ruff.toml | 1 - python/zensical/config.py | 16 ++++++++++------ python/zensical/extensions/search.py | 2 +- python/zensical/main.py | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index e6eebe2..2113a5e 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -53,7 +53,6 @@ ignore = [ "D105", # Missing docstring in magic method "D107", # Missing docstring in `__init__` method "D417", # Missing argument description in the docstring - "E501", # Line too long "ERA001", # Commented out code "FBT001", # Boolean positional parameter in function signature "FBT003", # Boolean positional value in function call diff --git a/python/zensical/config.py b/python/zensical/config.py index 07d14b5..c651de7 100644 --- a/python/zensical/config.py +++ b/python/zensical/config.py @@ -442,7 +442,10 @@ def _apply_defaults(config: dict, path: str) -> dict: def set_default( entry: dict, key: str, default: Any, data_type: type | None = None ) -> Any: - """Set a key to a default value if it isn't set, and optionally cast it to the specified data type.""" + """Set a key to a default value if it isn't set. + + Optionally cast it to the specified data type. + """ if key in entry and entry[key] is None: del entry[key] @@ -492,7 +495,7 @@ def _list_templates(config: dict) -> list[tuple[str, int]]: def _convert_extra(data: dict | list) -> dict | list: - """Recursively convert all None values in a dictionary or list to empty strings.""" + """Recursively convert None values in a dictionary/list to empty strings.""" if isinstance(data, dict): # Process each key-value pair in the dictionary return { @@ -528,7 +531,7 @@ def _convert_nav(nav: list) -> list: def _convert_nav_item(item: str | dict | list) -> dict | list: - """Convert MkDocs shorthand navigation structure into something more manageable. + """Convert MkDocs shorthand navigation structure into something manageable. We need to annotate each item with a title, URL, icon, and children. """ @@ -609,7 +612,7 @@ def _convert_extra_javascript(value: list) -> list: def _convert_markdown_extensions(value: Any) -> tuple[list[str], dict]: - """Convert Markdown extensions configuration to what Python Markdown expects.""" + """Convert Markdown extensions to what Python Markdown expects.""" markdown_extensions = ["toc", "tables"] mdx_configs: dict[str, dict[str, Any]] = {"toc": {}, "tables": {}} @@ -724,7 +727,7 @@ def _convert_plugins(value: Any, config: dict) -> dict: def _yaml_load( source: IO, loader: type[BaseLoader] | None = None ) -> dict[str, Any]: - """Load configuration file and resolve environment variables and parent files. + """Load configuration file, resolve environment variables and parent files. Note that INHERIT is only a bandaid that was introduced to allow for some degree of modularity, but with serious shortcomings. Zensical will use a @@ -756,7 +759,8 @@ def _yaml_load( ) if not os.path.exists(abspath): raise ConfigurationError( - f"Inherited config file '{relpath}' doesn't exist at '{abspath}'." + f"Inherited config file '{relpath}' " + f"doesn't exist at '{abspath}'." ) with open(abspath, encoding="utf-8") as fd: parent = _yaml_load(fd, loader) diff --git a/python/zensical/extensions/search.py b/python/zensical/extensions/search.py index 10ee709..fc9c7aa 100644 --- a/python/zensical/extensions/search.py +++ b/python/zensical/extensions/search.py @@ -34,7 +34,7 @@ from markdown.postprocessors import Postprocessor class SearchProcessor(Postprocessor): - """Post processor that extracts searchable content from the rendered HTML.""" + """Post processor to extract searchable content from the rendered HTML.""" def __init__(self, md: Markdown) -> None: super().__init__(md) diff --git a/python/zensical/main.py b/python/zensical/main.py index ae91f46..aeaa5fa 100644 --- a/python/zensical/main.py +++ b/python/zensical/main.py @@ -135,7 +135,7 @@ def execute_serve(config_file: str | None, **kwargs: Any) -> None: required=False, ) def new_project(directory: str | None, **kwargs: Any) -> None: # noqa: ARG001 - """Create a new template project in the current directory or in the given directory. + """Create a new template project in the current or given directory. Raises: ClickException: if the directory already contains a zensical.toml or a