From a012814ecafb458efb4decbfc8049ac37edc797c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Thu, 7 Nov 2024 11:40:52 +0100 Subject: [PATCH] chore: enable flake8-bugbear ruff rules --- canaille/app/configuration.py | 6 ++++-- canaille/backends/ldap/backend.py | 2 +- pyproject.toml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/canaille/app/configuration.py b/canaille/app/configuration.py index 556edef4..01d6bde1 100644 --- a/canaille/app/configuration.py +++ b/canaille/app/configuration.py @@ -132,8 +132,10 @@ def toml_content(file_path): with open(file_path, "rb") as fd: return tomllib.load(fd) - except ImportError: - raise Exception("toml library not installed. Cannot load configuration.") + except ImportError as exc: + raise Exception( + "toml library not installed. Cannot load configuration." + ) from exc def setup_config(app, config=None, test_config=True, env_file=".env", env_prefix=""): diff --git a/canaille/backends/ldap/backend.py b/canaille/backends/ldap/backend.py index 2d39b770..d96262cd 100644 --- a/canaille/backends/ldap/backend.py +++ b/canaille/backends/ldap/backend.py @@ -264,7 +264,7 @@ class LDAPBackend(Backend): class_filter = ( "".join([f"(objectClass={oc})" for oc in model.ldap_object_class]) - if getattr(model, "ldap_object_class") + if model.ldap_object_class else "" ) if class_filter: diff --git a/pyproject.toml b/pyproject.toml index 58f47616..4186c737 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -170,6 +170,7 @@ exclude_lines = [ [tool.ruff.lint] select = [ + "B", # flake8-bugbear "E", # pycodestyle "F", # pyflakes "I", # isort