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

♻ Instantiate HTTPException only when needed, optimization refactor #5356

Merged
merged 4 commits into from
Jun 10, 2023

Conversation

pawamoy
Copy link
Sponsor Contributor

@pawamoy pawamoy commented Sep 7, 2022

Hello, just noticed this while debugging something.

If we enter the condition if not authorization or scheme.lower() != "basic", the instance of HTTPException happens to be unused.
I moved it lower to avoid instantiating it without using it.

@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (cf73051) 100.00% compared to head (ceef3e0) 100.00%.

❗ Current head ceef3e0 differs from pull request most recent head c81b353. Consider uploading reports for the commit c81b353 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #5356   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          540       539    -1     
  Lines        13969     13906   -63     
=========================================
- Hits         13969     13906   -63     
Impacted Files Coverage Δ
fastapi/security/http.py 100.00% <100.00%> (ø)

... and 15 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2022

📝 Docs preview for commit ceef3e0 at: https://6318590be6f7d21003d370e7--fastapi.netlify.app

Copy link
Contributor

@mbroton mbroton left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@iudeen iudeen left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@JarroVGIT JarroVGIT left a comment

Choose a reason for hiding this comment

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

LGTM, nice catch!

@github-actions
Copy link
Contributor

📝 Docs preview for commit 80e7113 at: https://63961f74add2564518f5becd--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 845d2a4 at: https://639ce44fecf1fd06b69b432b--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit c81b353 at: https://6439025af11ac4226e68ca88--fastapi.netlify.app

@tiangolo tiangolo changed the title Instantiate HTTPException only when needed ♻ Instantiate HTTPException only when needed, optimization refactor Jun 10, 2023
@tiangolo
Copy link
Owner

Great, thank you! 🚀

And thanks everyone for the reviews. 🤓

@tiangolo tiangolo merged commit 010d44e into tiangolo:master Jun 10, 2023
8 checks passed
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.

None yet

8 participants