From 4105ae27d1ca0449b349974d3553db7c28bbfeef Mon Sep 17 00:00:00 2001 From: Shunichiro Nomura Date: Sat, 3 Feb 2024 18:00:27 +0900 Subject: [PATCH 1/4] Update ruff setting section name --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f9f1f30a..7266f3e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,8 @@ ignore_missing_imports = true [tool.ruff] target-version = "py38" line-length = 120 + +[tool.ruff.lint] select = ["ALL"] ignore = [ "PLR2004", # magic numbers @@ -81,14 +83,14 @@ ignore = [ ] -[tool.ruff.flake8-type-checking] +[tool.ruff.lint.flake8-type-checking] runtime-evaluated-base-classes = ["pydantic.BaseModel"] -[tool.ruff.pyupgrade] +[tool.ruff.lint.pyupgrade] # Keep runtime typing for Pydantic. keep-runtime-typing = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "examples/*" = [ "INP001", # implicit-namespace-package ] From b01b26d1bf5e07842bd65528a5c502adca92440c Mon Sep 17 00:00:00 2001 From: Shunichiro Nomura Date: Sat, 3 Feb 2024 18:01:15 +0900 Subject: [PATCH 2/4] enable RUF022 rule --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7266f3e2..d4fe531f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,10 @@ target-version = "py38" line-length = 120 [tool.ruff.lint] -select = ["ALL"] +preview = true +explicit-preview-rules = true + +select = ["ALL", "RUF022"] ignore = [ "PLR2004", # magic numbers "S101", # use of assert From f968024e03242a77b806992b43da1e7848f03777 Mon Sep 17 00:00:00 2001 From: Shunichiro Nomura Date: Sat, 3 Feb 2024 18:02:38 +0900 Subject: [PATCH 3/4] sort __all__ section --- capsula/__init__.py | 34 +++++++++++++++++----------------- capsula/_backport.py | 2 +- capsula/_context/__init__.py | 6 +++--- capsula/_monitor.py | 16 ++++++++-------- capsula/_watcher/__init__.py | 2 +- capsula/config.py | 6 +++--- capsula/context_deprecated.py | 12 ++++++------ capsula/exceptions.py | 2 +- capsula/globalvars.py | 4 ++-- 9 files changed, 42 insertions(+), 42 deletions(-) diff --git a/capsula/__init__.py b/capsula/__init__.py index fbc77e69..bb56d5a8 100644 --- a/capsula/__init__.py +++ b/capsula/__init__.py @@ -1,32 +1,32 @@ __all__ = [ - "monitor", - "__version__", "CapsulaConfigurationError", "CapsulaError", - "get_capsule_dir", - "get_capsule_name", - "set_capsule_dir", - "set_capsule_name", - "Encapsulator", - "record", - "Run", + "CommandContext", "ContextBase", + "CpuContext", "CwdContext", + "Encapsulator", "EnvVarContext", - "GitRepositoryContext", "FileContext", - "PlatformContext", - "CpuContext", - "CommandContext", + "GitRepositoryContext", "JsonDumpReporter", + "PlatformContext", "ReporterBase", - "WatcherBase", + "Run", "TimeWatcher", - "watcher", - "reporter", - "context", "UncaughtExceptionWatcher", + "WatcherBase", + "__version__", + "context", + "get_capsule_dir", + "get_capsule_name", + "monitor", + "record", + "reporter", "run", + "set_capsule_dir", + "set_capsule_name", + "watcher", ] from ._context import ( CommandContext, diff --git a/capsula/_backport.py b/capsula/_backport.py index 00bb83d1..913da585 100644 --- a/capsula/_backport.py +++ b/capsula/_backport.py @@ -1,6 +1,6 @@ from __future__ import annotations -__all__ = ["TypeAlias", "file_digest", "Self", "ParamSpec"] +__all__ = ["ParamSpec", "Self", "TypeAlias", "file_digest"] import hashlib import sys diff --git a/capsula/_context/__init__.py b/capsula/_context/__init__.py index 23519d45..79b566d3 100644 --- a/capsula/_context/__init__.py +++ b/capsula/_context/__init__.py @@ -1,12 +1,12 @@ __all__ = [ + "CommandContext", "ContextBase", + "CpuContext", "CwdContext", "EnvVarContext", - "GitRepositoryContext", "FileContext", + "GitRepositoryContext", "PlatformContext", - "CpuContext", - "CommandContext", ] from ._base import ContextBase from ._command import CommandContext diff --git a/capsula/_monitor.py b/capsula/_monitor.py index c64dfc6a..ebf45c14 100644 --- a/capsula/_monitor.py +++ b/capsula/_monitor.py @@ -1,16 +1,16 @@ __all__ = [ - "PreRunInfoBase", - "PreRunInfoCli", - "PreRunInfoFunc", - "OutputFileInfo", - "PostRunInfoBase", - "PostRunInfoCli", - "PostRunInfoFunc", "ExceptionInfo", - "OutputFileInfo", "MonitoringHandlerBase", "MonitoringHandlerCli", "MonitoringHandlerFunc", + "OutputFileInfo", + "OutputFileInfo", + "PostRunInfoBase", + "PostRunInfoCli", + "PostRunInfoFunc", + "PreRunInfoBase", + "PreRunInfoCli", + "PreRunInfoFunc", "monitor", ] import inspect diff --git a/capsula/_watcher/__init__.py b/capsula/_watcher/__init__.py index 32a2fa0c..318c401a 100644 --- a/capsula/_watcher/__init__.py +++ b/capsula/_watcher/__init__.py @@ -1,4 +1,4 @@ -__all__ = ["WatcherBase", "TimeWatcher", "UncaughtExceptionWatcher"] +__all__ = ["TimeWatcher", "UncaughtExceptionWatcher", "WatcherBase"] from ._base import WatcherBase from ._exception import UncaughtExceptionWatcher from ._time import TimeWatcher diff --git a/capsula/config.py b/capsula/config.py index 03b7ace0..57d9ae7d 100644 --- a/capsula/config.py +++ b/capsula/config.py @@ -1,9 +1,9 @@ __all__ = [ - "GitConfig", + "CapsulaConfig", "CaptureConfig", - "MonitorItemConfig", + "GitConfig", "MonitorConfig", - "CapsulaConfig", + "MonitorItemConfig", ] import sys from datetime import datetime diff --git a/capsula/context_deprecated.py b/capsula/context_deprecated.py index d0c74f91..19bc73f7 100644 --- a/capsula/context_deprecated.py +++ b/capsula/context_deprecated.py @@ -1,12 +1,12 @@ __all__ = [ - "ContextItem", "Architecture", - "PythonInfo", - "Platform", - "GitRemote", - "GitInfo", - "FileContext", "Context", + "ContextItem", + "FileContext", + "GitInfo", + "GitRemote", + "Platform", + "PythonInfo", ] import os import platform as pf diff --git a/capsula/exceptions.py b/capsula/exceptions.py index 01575c6e..47374382 100644 --- a/capsula/exceptions.py +++ b/capsula/exceptions.py @@ -1,4 +1,4 @@ -__all__ = ["CapsulaError", "CapsulaConfigurationError"] +__all__ = ["CapsulaConfigurationError", "CapsulaError"] class CapsulaError(Exception): diff --git a/capsula/globalvars.py b/capsula/globalvars.py index 9c73c7f2..1929d852 100644 --- a/capsula/globalvars.py +++ b/capsula/globalvars.py @@ -1,8 +1,8 @@ __all__ = [ - "set_capsule_dir", "get_capsule_dir", - "set_capsule_name", "get_capsule_name", + "set_capsule_dir", + "set_capsule_name", ] import os from pathlib import Path From 30db7d44612249f4184103029d1d14d9ad1346c2 Mon Sep 17 00:00:00 2001 From: Shunichiro Nomura Date: Sat, 3 Feb 2024 18:05:12 +0900 Subject: [PATCH 4/4] Refactor variable naming in run_and_teardown method --- capsula/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capsula/__main__.py b/capsula/__main__.py index 8ecc2446..59887040 100644 --- a/capsula/__main__.py +++ b/capsula/__main__.py @@ -99,7 +99,7 @@ def monitor(ctx: click.Context, items: Iterable[str], args: tuple[str]) -> None: handler = MonitoringHandlerCli(config=config) pre_run_info = handler.setup(args) - post_run_info, exc = handler.run_and_teardown(pre_run_info=pre_run_info, items=items) + post_run_info, _exc = handler.run_and_teardown(pre_run_info=pre_run_info, items=items) # propagate the exit code ctx.exit(post_run_info.exit_code)