From 920003695d14c47c0289274cca213bca83a622b1 Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Tue, 28 May 2024 15:35:24 +0200 Subject: [PATCH] Ignore TRY003 (too long exception message) globally --- pyproject.toml | 1 + tad/core/config.py | 2 +- tad/migrations/env.py | 2 +- tad/services/storage.py | 2 +- tests/core/test_exceptions.py | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 58ac1574..5b35b265 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ build-backend = "poetry.core.masonry.api" line-length = 120 target-version = "py311" src = ["tad","tests"] +ignore = ["TRY003"] [tool.ruff.format] line-ending = "lf" diff --git a/tad/core/config.py b/tad/core/config.py index e178109d..3929cc31 100644 --- a/tad/core/config.py +++ b/tad/core/config.py @@ -87,7 +87,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> str: @model_validator(mode="after") def _enforce_database_rules(self: SelfSettings) -> SelfSettings: if self.ENVIRONMENT != "local" and self.APP_DATABASE_SCHEME == "sqlite": - raise SettingsError("SQLite is not supported in production") # noqa: TRY003 + raise SettingsError("SQLite is not supported in production") return self diff --git a/tad/migrations/env.py b/tad/migrations/env.py index f8e8ffcd..37521559 100644 --- a/tad/migrations/env.py +++ b/tad/migrations/env.py @@ -58,7 +58,7 @@ def run_migrations_online(): """ configuration = config.get_section(config.config_ini_section) if configuration is None: - raise Exception("Failed to get configuration section") # noqa: TRY003, TRY002 + raise Exception("Failed to get configuration section") # noqa: TRY002 configuration["sqlalchemy.url"] = get_url() connectable = engine_from_config( configuration, diff --git a/tad/services/storage.py b/tad/services/storage.py index 1614adc4..e85ce3a4 100644 --- a/tad/services/storage.py +++ b/tad/services/storage.py @@ -8,7 +8,7 @@ class WriteService(ABC): def __init__(self, location: str, filename: str) -> None: self.location = location if not filename.endswith(".yaml"): - raise ValueError(f"Filename {filename} must end with .yaml instead of .{filename.split('.')[-1]}") # noqa: TRY003 + raise ValueError(f"Filename {filename} must end with .yaml instead of .{filename.split('.')[-1]}") self.filename = filename @abstractmethod diff --git a/tests/core/test_exceptions.py b/tests/core/test_exceptions.py index 62891784..a2801466 100644 --- a/tests/core/test_exceptions.py +++ b/tests/core/test_exceptions.py @@ -4,6 +4,6 @@ def test_environment_settings(): with pytest.raises(SettingsError) as exc_info: - raise SettingsError("Wrong settings") # noqa: TRY003 + raise SettingsError("Wrong settings") assert exc_info.value.message == "Wrong settings"