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

♻️ Move duplicated code portion to a static method in the APIKeyBase super class #3142

Merged

Conversation

ShahriyarR
Copy link
Contributor

The code block below was used 3 times:

        if not api_key:
            if auto_error:
                raise HTTPException(
                    status_code=HTTP_403_FORBIDDEN, detail="Not authenticated"
                )
            else:
                return None
        return api_key

I have moved this portion to the staticmethod into the super class as it will be shared by inheritance to all 3 subclasses.

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2021

📝 Docs preview for commit 4a80d02 at: https://608d27c61facd91cca0729bf--fastapi.netlify.app

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #3142 (8ce0578) into master (ce0ec06) will not change coverage.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##            master     #3142     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          243       531    +288     
  Lines         7419     13623   +6204     
===========================================
+ Hits          7419     13623   +6204     
Impacted Files Coverage Δ
fastapi/security/api_key.py 100.00% <100.00%> (ø)
fastapi/params.py 100.00% <0.00%> (ø)
fastapi/routing.py 100.00% <0.00%> (ø)
fastapi/encoders.py 100.00% <0.00%> (ø)
fastapi/responses.py 100.00% <0.00%> (ø)
fastapi/exceptions.py 100.00% <0.00%> (ø)
fastapi/concurrency.py 100.00% <0.00%> (ø)
fastapi/applications.py 100.00% <0.00%> (ø)
fastapi/openapi/docs.py 100.00% <0.00%> (ø)
tests/test_ws_router.py 100.00% <0.00%> (ø)
... and 318 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2252837...8ce0578. Read the comment docs.

@github-actions
Copy link
Contributor

📝 Docs preview for commit 8ce0578 at: https://627e2fec25b877508f6395dc--fastapi.netlify.app

Copy link

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

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

Nice!

@svlandeg
Copy link
Member

svlandeg commented Aug 14, 2024

@patrick91 : could you have another look at this PR, as it's not succeeding the linting step? 🙏

[Update]: I've gone in and fixed it 😉

@svlandeg svlandeg self-assigned this Sep 3, 2024
@svlandeg svlandeg changed the title Moved duplicated code portion to the staticmethod in the super class ♻️ Move duplicated code portion to a static method in the APIKeyBase super class Sep 3, 2024
@svlandeg svlandeg removed their assignment Sep 3, 2024
Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

Nice, thank you! 🚀

And thanks for the reviews and help! ☕

@tiangolo tiangolo merged commit 30b270b into fastapi:master Jan 30, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants