Skip to content
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

Replace sqlalchemy backref parameter with back_populates #2123

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

jonathangreen
Copy link
Member

Description

This PR updates all references to backref to use back_populates as sqlalchmey recommends as the current best practice. This PR also tweaks some of the flags we use for mypy only in our tests, to disable some of the mypy warnings that aren't very meaningful for tests.

Motivation and Context

The sqlalchemy backref parameter is considered legacy see: https://docs.sqlalchemy.org/en/14/orm/backref.html. Using this construct means that mypy (and IDE) can't infer the type of the dynamically generated parameter.

This is part of the effort to get the code to a place where we can enable check_untyped_defs in mypy.

How Has This Been Tested?

  • Running tests

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen requested a review from a team October 18, 2024 18:38
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.74%. Comparing base (b286414) to head (7e3628b).
Report is 6 commits behind head on chore/mypy-config-tests.

Additional details and impacted files
@@                   Coverage Diff                    @@
##           chore/mypy-config-tests    #2123   +/-   ##
========================================================
  Coverage                    90.73%   90.74%           
========================================================
  Files                          351      351           
  Lines                        40904    40934   +30     
  Branches                      8874     8871    -3     
========================================================
+ Hits                         37115    37146   +31     
  Misses                        2481     2481           
+ Partials                      1308     1307    -1     

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

@jonathangreen jonathangreen changed the base branch from main to chore/mypy-config-tests October 18, 2024 18:48
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🔧

Copy link
Contributor

@tdilauro tdilauro Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to tests/manager/api/controller/test_work.py don't seem strictly necessary, but I don't see any problem with them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I forget why i changed this file... maybe for mypy? I'm not sure now, i guess i should have put a comment on this one.

@jonathangreen jonathangreen merged commit aa92fd1 into chore/mypy-config-tests Oct 22, 2024
20 checks passed
@jonathangreen jonathangreen deleted the chore/replace-backref branch October 22, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants