Skip to content

Fix deprecated useage of FastAPI Depends#12531

Merged
berland merged 1 commit intoequinor:mainfrom
berland:fast_typing
Dec 22, 2025
Merged

Fix deprecated useage of FastAPI Depends#12531
berland merged 1 commit intoequinor:mainfrom
berland:fast_typing

Conversation

@berland
Copy link
Contributor

@berland berland commented Dec 19, 2025

fast-api-non-annotated-dependency (FAST002)

Derived from the FastAPI linter.

Fix is sometimes available.

Identifies FastAPI routes with deprecated uses of Depends or similar.

The [FastAPI documentation] recommends the use of [typing.Annotated][typing-annotated] for defining route dependencies and parameters, rather than using Depends, Query or similar as a default value for a parameter. Using this approach everywhere helps ensure consistency and clarity in defining dependencies and parameters.

Annotated was added to the typing module in Python 3.9; however, the third-party [typing_extensions][typing-extensions] package provides a backport that can be used on older versions of Python.

Issue
Resolves ruff FAST issue.

Approach
ruff check --fix --unsafe-fixes

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

fast-api-non-annotated-dependency (FAST002)

Derived from the **FastAPI** linter.

Fix is sometimes available.

Identifies FastAPI routes with deprecated uses of `Depends` or similar.

The [FastAPI documentation] recommends the use of [`typing.Annotated`][typing-annotated]
for defining route dependencies and parameters, rather than using `Depends`,
`Query` or similar as a default value for a parameter. Using this approach
everywhere helps ensure consistency and clarity in defining dependencies
and parameters.

`Annotated` was added to the `typing` module in Python 3.9; however,
the third-party [`typing_extensions`][typing-extensions] package
provides a backport that can be used on older versions of Python.
@berland berland added this to SCOUT Dec 19, 2025
@berland berland moved this to In Progress in SCOUT Dec 19, 2025
@berland berland self-assigned this Dec 19, 2025
@berland berland added the release-notes:maintenance Automatically categorise as maintenance change in release notes label Dec 19, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (19228a0) to head (b3fd85f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12531      +/-   ##
==========================================
- Coverage   90.67%   90.65%   -0.02%     
==========================================
  Files         431      431              
  Lines       29720    29721       +1     
==========================================
- Hits        26948    26945       -3     
- Misses       2772     2776       +4     
Flag Coverage Δ
cli-tests 37.61% <0.00%> (-0.01%) ⬇️
gui-tests 68.73% <0.00%> (-0.01%) ⬇️
performance-and-unit-tests 74.15% <100.00%> (-0.02%) ⬇️
test 38.36% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 19, 2025

CodSpeed Performance Report

Merging #12531 will not alter performance

Comparing berland:fast_typing (b3fd85f) with main (19228a0)

Summary

✅ 22 untouched

@berland berland moved this from In Progress to Ready for Review in SCOUT Dec 22, 2025
Copy link
Contributor

@andreas-el andreas-el left a comment

Choose a reason for hiding this comment

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

💯

@github-project-automation github-project-automation bot moved this from Ready for Review to Reviewed in SCOUT Dec 22, 2025
@berland berland merged commit 86fe831 into equinor:main Dec 22, 2025
36 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in SCOUT Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes:maintenance Automatically categorise as maintenance change in release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants