Skip to content

fix(types): correct type hints for with_for_update to ForUpdateParameter #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PrinterOMG
Copy link

Description

This change fixes the type hint for the with_for_update parameter in the repositories. Currently, the type hint is Optional[bool], but according to the method's docstring, with_for_update is described as: "indicating FOR UPDATE should be used, or may be a dictionary containing flags to indicate a more specific set of FOR UPDATE flags for the SELECT". This implies that a dictionary may be passed, but the current type hint doesn’t reflect that.

If we trace where with_for_update is passed, it ends up unchanged in session.refresh in SQLAlchemy, which has the type hint ForUpdateParameter = Union["ForUpdateArg", None, bool, Dict[str, Any]], and that’s what I updated the type hints in our code to match.

However, it’s possible that this isn’t what was originally intended, and I’m not sure if this is the correct fix. There are other ways to address the issue — which approach would be preferable?

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.15%. Comparing base (00e4ac2) to head (380275a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #465   +/-   ##
=======================================
  Coverage   88.14%   88.15%           
=======================================
  Files          84       84           
  Lines        5508     5512    +4     
  Branches      677      677           
=======================================
+ Hits         4855     4859    +4     
  Misses        445      445           
  Partials      208      208           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/advanced-alchemy-docs-preview/465

@PrinterOMG PrinterOMG marked this pull request as ready for review May 1, 2025 06:08
@PrinterOMG PrinterOMG requested review from a team as code owners May 1, 2025 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants