Skip to content

Commit

Permalink
Improve readability of alchemy checker
Browse files Browse the repository at this point in the history
Avoid broad `except AttributeError`.
  • Loading branch information
rbarrois committed Aug 17, 2024
1 parent d6349de commit 8aaa29b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions factory/alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ def _check_sqlalchemy_session_persistence(self, meta, value):

@staticmethod
def _check_has_sqlalchemy_session_set(meta, value):
try:
if value and meta.sqlalchemy_session:
raise RuntimeError("Provide either a sqlalchemy_session or a sqlalchemy_session_factory, not both")
except AttributeError:
pass
if value is not None and getattr(meta, "sqlalchemy_session", None) is not None:
raise RuntimeError("Provide either a sqlalchemy_session or a sqlalchemy_session_factory, not both")

def _build_default_options(self):
return super()._build_default_options() + [
Expand Down

0 comments on commit 8aaa29b

Please sign in to comment.