Other code improvements #85
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code Improvements
This PR contains several minor code quality improvements:
Remove duplicate license header - Removed duplicate partial MIT license block in
_repository/abstract.pyRemove unnecessary
partialwrapper - Thepartial()wrapper in_filter_order_bywas not needed sinceascanddesccan be referenced directly as callablesRemove deprecated
future=Trueengine option - This option is deprecated in SQLAlchemy 2.0 and is now the default behaviorRemove redundant
or []fallback - Incursor_paginated_find, the list comprehension already produces a list, making theor []fallback unnecessaryAdd exception handling to
SessionHandler.__del__- Thescoped_session.remove()call could fail if the database connection is already closed during garbage collection. Wrapping in try/except withdebug logging prevents errors during interpreter shutdown
Use
any()for more efficient model validation - Replaces list comprehension withany()generator expression to short-circuit on first invalid model instead of iterating all itemsExtract shared primary key utility function - Consolidates duplicated PK inspection logic from
BaseRepository._model_pk()andresult_presenters._pk_from_result_object()into a singleget_model_pk_name()function incommon.py