diff --git a/poetry.lock b/poetry.lock index 917d160..e5f1e0a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1893,28 +1893,29 @@ idna2008 = ["idna"] [[package]] name = "ruff" -version = "0.1.15" +version = "0.7.1" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:5fe8d54df166ecc24106db7dd6a68d44852d14eb0729ea4672bb4d96c320b7df"}, - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f0bfbb53c4b4de117ac4d6ddfd33aa5fc31beeaa21d23c45c6dd249faf9126f"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0d432aec35bfc0d800d4f70eba26e23a352386be3a6cf157083d18f6f5881c8"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9405fa9ac0e97f35aaddf185a1be194a589424b8713e3b97b762336ec79ff807"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66ec24fe36841636e814b8f90f572a8c0cb0e54d8b5c2d0e300d28a0d7bffec"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6f8ad828f01e8dd32cc58bc28375150171d198491fc901f6f98d2a39ba8e3ff5"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86811954eec63e9ea162af0ffa9f8d09088bab51b7438e8b6488b9401863c25e"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd4025ac5e87d9b80e1f300207eb2fd099ff8200fa2320d7dc066a3f4622dc6b"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b17b93c02cdb6aeb696effecea1095ac93f3884a49a554a9afa76bb125c114c1"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ddb87643be40f034e97e97f5bc2ef7ce39de20e34608f3f829db727a93fb82c5"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:abf4822129ed3a5ce54383d5f0e964e7fef74a41e48eb1dfad404151efc130a2"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6c629cf64bacfd136c07c78ac10a54578ec9d1bd2a9d395efbee0935868bf852"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1bab866aafb53da39c2cadfb8e1c4550ac5340bb40300083eb8967ba25481447"}, - {file = "ruff-0.1.15-py3-none-win32.whl", hash = "sha256:2417e1cb6e2068389b07e6fa74c306b2810fe3ee3476d5b8a96616633f40d14f"}, - {file = "ruff-0.1.15-py3-none-win_amd64.whl", hash = "sha256:3837ac73d869efc4182d9036b1405ef4c73d9b1f88da2413875e34e0d6919587"}, - {file = "ruff-0.1.15-py3-none-win_arm64.whl", hash = "sha256:9a933dfb1c14ec7a33cceb1e49ec4a16b51ce3c20fd42663198746efc0427360"}, - {file = "ruff-0.1.15.tar.gz", hash = "sha256:f6dfa8c1b21c913c326919056c390966648b680966febcb796cc9d1aaab8564e"}, + {file = "ruff-0.7.1-py3-none-linux_armv6l.whl", hash = "sha256:cb1bc5ed9403daa7da05475d615739cc0212e861b7306f314379d958592aaa89"}, + {file = "ruff-0.7.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:27c1c52a8d199a257ff1e5582d078eab7145129aa02721815ca8fa4f9612dc35"}, + {file = "ruff-0.7.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:588a34e1ef2ea55b4ddfec26bbe76bc866e92523d8c6cdec5e8aceefeff02d99"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94fc32f9cdf72dc75c451e5f072758b118ab8100727168a3df58502b43a599ca"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:985818742b833bffa543a84d1cc11b5e6871de1b4e0ac3060a59a2bae3969250"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:32f1e8a192e261366c702c5fb2ece9f68d26625f198a25c408861c16dc2dea9c"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:699085bf05819588551b11751eff33e9ca58b1b86a6843e1b082a7de40da1565"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:344cc2b0814047dc8c3a8ff2cd1f3d808bb23c6658db830d25147339d9bf9ea7"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4316bbf69d5a859cc937890c7ac7a6551252b6a01b1d2c97e8fc96e45a7c8b4a"}, + {file = "ruff-0.7.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79d3af9dca4c56043e738a4d6dd1e9444b6d6c10598ac52d146e331eb155a8ad"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:c5c121b46abde94a505175524e51891f829414e093cd8326d6e741ecfc0a9112"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:8422104078324ea250886954e48f1373a8fe7de59283d747c3a7eca050b4e378"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:56aad830af8a9db644e80098fe4984a948e2b6fc2e73891538f43bbe478461b8"}, + {file = "ruff-0.7.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:658304f02f68d3a83c998ad8bf91f9b4f53e93e5412b8f2388359d55869727fd"}, + {file = "ruff-0.7.1-py3-none-win32.whl", hash = "sha256:b517a2011333eb7ce2d402652ecaa0ac1a30c114fbbd55c6b8ee466a7f600ee9"}, + {file = "ruff-0.7.1-py3-none-win_amd64.whl", hash = "sha256:f38c41fcde1728736b4eb2b18850f6d1e3eedd9678c914dede554a70d5241307"}, + {file = "ruff-0.7.1-py3-none-win_arm64.whl", hash = "sha256:19aa200ec824c0f36d0c9114c8ec0087082021732979a359d6f3c390a6ff2a37"}, + {file = "ruff-0.7.1.tar.gz", hash = "sha256:9d8a41d4aa2dad1575adb98a82870cf5db5f76b2938cf2206c22c940034a36f4"}, ] [[package]] @@ -2191,4 +2192,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.9,<3.12" -content-hash = "dfa5d2a2cacae3dcdba0284ed34569b8316a182cf1f59de4f66b09f9200d7e7a" +content-hash = "c4cb992f21b82631bd4a6dca17f7c7cbdcc616f0c9be191b2815283b7a94dca6" diff --git a/pyproject.toml b/pyproject.toml index a3bbaed..f0b8279 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,6 @@ exclude = ['tests/'] module = [ "jsonpatch", "jsonpointer", - "qualibrate", "qualibrate_app.*", "qualibrate_runner.*", "json_timeline_database.*", @@ -58,13 +57,25 @@ ignore_missing_imports = true [tool.ruff] line-length = 80 -extend-select = ["I"] target-version = "py39" +[tool.ruff.lint] +select = [ + "E", # pycodestyle + "F", # Pyflakes + "UP", # pyupgrade + "B", # flake8-bugbear + "SIM", # flake8-simplify + "I", # isort +] + +[tool.ruff.lint.pycodestyle] +max-line-length = 80 +max-doc-length = 80 [tool.poe.tasks] -lint = "ruff ." -lint-fix = "ruff --fix ." +lint = "ruff check ." +lint-fix = "ruff check --fix ." format = "ruff format --check ." format-fix = "ruff format ." type = "mypy ." diff --git a/qualibrate_composite/cli/config.py b/qualibrate_composite/cli/config.py index feb2461..9da1a17 100644 --- a/qualibrate_composite/cli/config.py +++ b/qualibrate_composite/cli/config.py @@ -1,9 +1,10 @@ import os import sys +from collections.abc import Mapping from importlib.util import find_spec from itertools import filterfalse from pathlib import Path -from typing import Any, Dict, Mapping, Optional +from typing import Any, Optional import click import tomli_w @@ -67,7 +68,6 @@ QualibrateRunnerSettings, ) - __all__ = ["config_command"] @@ -105,28 +105,28 @@ def _qualibrate_config_from_sources( } for arg_key, arg_value in ctx.params.items(): not_default_arg = not_default(ctx, arg_key) - if arg_key in qualibrate_composite_mapping.keys(): + if arg_key in qualibrate_composite_mapping: if not_default_arg or ( qualibrate_composite_mapping[arg_key] not in from_file ): from_file[qualibrate_composite_mapping[arg_key]] = arg_value - elif arg_key in qualibrate_app_mapping.keys(): + elif arg_key in qualibrate_app_mapping: if not_default_arg or ( qualibrate_app_mapping[arg_key] not in from_file["app"] ): from_file["app"][qualibrate_app_mapping[arg_key]] = arg_value - elif arg_key in timeline_db_mapping.keys(): + elif arg_key in timeline_db_mapping: if not_default_arg or ( timeline_db_mapping[arg_key] not in from_file["timeline_db"] ): - from_file["timeline_db"][ - timeline_db_mapping[arg_key] - ] = arg_value - elif arg_key in runner_mapping.keys(): - if not_default_arg or ( - runner_mapping[arg_key] not in from_file["runner"] - ): - from_file["runner"][runner_mapping[arg_key]] = arg_value + from_file["timeline_db"][timeline_db_mapping[arg_key]] = ( + arg_value + ) + elif arg_key in runner_mapping and ( + not_default_arg + or (runner_mapping[arg_key] not in from_file["runner"]) + ): + from_file["runner"][runner_mapping[arg_key]] = arg_value return from_file @@ -169,7 +169,7 @@ def _confirm(config_file: Path, exported_data: dict[str, Any]) -> None: def _get_runner_config( - ctx: click.Context, from_file: Dict[str, Any] + ctx: click.Context, from_file: dict[str, Any] ) -> QualibrateRunnerSettings: if qualibrate is None: raise ImportError("Qualibrate is not installed") @@ -190,7 +190,7 @@ def _get_runner_config( def _get_qapp_config( - ctx: click.Context, qs: QualibrateSettings, from_file: Dict[str, Any] + ctx: click.Context, qs: QualibrateSettings, from_file: dict[str, Any] ) -> QualibrateAppSettingsSetup: args_mapping = { "app_static_site_files": "static_site_files", @@ -220,7 +220,7 @@ def _get_qapp_config( def _get_qapp_am_config( - ctx: click.Context, from_file: Dict[str, Any] + ctx: click.Context, from_file: dict[str, Any] ) -> ActiveMachineSettingsSetup: args_mapping = {"active_machine_path": "path"} data = { @@ -237,7 +237,7 @@ def _get_qapp_am_config( def _get_qapp_q_config( - ctx: click.Context, from_file: Dict[str, Any] + ctx: click.Context, from_file: dict[str, Any] ) -> QualibrateAppQSettingsSetup: storage_keys = { "app_storage_type": "type", @@ -268,7 +268,7 @@ def _get_qapp_q_config( return QualibrateAppQSettingsSetup(**from_file) -def reorder_common_config_entries(data: Dict[str, Any]) -> Dict[str, Any]: +def reorder_common_config_entries(data: dict[str, Any]) -> dict[str, Any]: sorted_keys = ( QAPP_Q_CONFIG_KEY, QUALIBRATE_CONFIG_KEY, diff --git a/qualibrate_composite/config/references/resolvers.py b/qualibrate_composite/config/references/resolvers.py index 5f344af..ed8296f 100644 --- a/qualibrate_composite/config/references/resolvers.py +++ b/qualibrate_composite/config/references/resolvers.py @@ -1,5 +1,6 @@ from collections import defaultdict -from typing import Any, List, Mapping, Optional, Sequence, Set, Tuple, cast +from collections.abc import Mapping, Sequence +from typing import Any, Optional, cast import jsonpatch import jsonpointer @@ -14,7 +15,7 @@ def find_references_in_str( to_search: str, config_path: str ) -> Sequence[Reference]: - to_resolve: List[Reference] = [] + to_resolve: list[Reference] = [] template_start_index = to_search.find(TEMPLATE_START) while template_start_index != -1: template_end_index = to_search.find("}", template_start_index) @@ -53,7 +54,7 @@ def find_all_references( def check_cycles_in_references( references: Mapping[str, Sequence[str]], -) -> Tuple[bool, Optional[Sequence[str]]]: +) -> tuple[bool, Optional[Sequence[str]]]: """Return True if the references has a cycle. >>> check_cycles_in_references({"a": ("b",), "b": ("c",), "c": ("a",)}) @@ -62,8 +63,8 @@ def check_cycles_in_references( (False, None) """ - path: List[str] = [] - visited: Set[str] = set() + path: list[str] = [] + visited: set[str] = set() cycled_item: str = "" def visit(vertex: str) -> bool: