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

Helper function to get flask.request.admin #2179

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

jonathangreen
Copy link
Member

Description

Similar to #2177 but for flask.request.admin.

Add a helper function get_request_admin() to get flask.request.admin in a type safe way. Update the existing code to use the new helper.

Motivation and Context

Consistency in how we are accessing attributes set on flask.request.

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 November 20, 2024 18:11
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.01%. Comparing base (30f2547) to head (774e56f).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2179      +/-   ##
==========================================
+ Coverage   91.00%   91.01%   +0.01%     
==========================================
  Files         359      361       +2     
  Lines       41136    41193      +57     
  Branches     8842     8845       +3     
==========================================
+ Hits        37436    37493      +57     
  Misses       2424     2424              
  Partials     1276     1276              

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


🚨 Try these New Features:

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.

Requested one change, but otherwise looks good. 🛠️

@@ -61,7 +62,8 @@ def process_get(self) -> Response:

for library in libraries:
# Only include libraries this admin has librarian access to.
if not flask.request.admin or not flask.request.admin.is_librarian(library): # type: ignore[attr-defined]
admin = get_request_admin(default=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Change request: We should move this assignment outside of the loop.

Base automatically changed from chore/type-hint-request-library to main November 20, 2024 20:15
@jonathangreen jonathangreen force-pushed the chore/type-hint-request-admin branch from 1440954 to 774e56f Compare November 20, 2024 20:21
@jonathangreen jonathangreen merged commit 1d1b4eb into main Nov 20, 2024
21 checks passed
@jonathangreen jonathangreen deleted the chore/type-hint-request-admin branch November 20, 2024 20:32
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