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

prefer more generic Mapping over dict type #10

Merged
merged 2 commits into from
Jul 16, 2024

Conversation

edvardm
Copy link
Contributor

@edvardm edvardm commented Jul 11, 2024

typically it's better to specify more generic types for input parameters, and specific types our return values. In this case changing headers param from dict to Mapping should resolve typing issues when eg. starlette.requests.headers.Headers instance is passed to get_principal_from_headers()

@edvardm edvardm marked this pull request as ready for review July 11, 2024 09:34
@edvardm edvardm requested a review from a team as a code owner July 11, 2024 09:34
Copy link
Contributor

@sinanislekdemir sinanislekdemir left a comment

Choose a reason for hiding this comment

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

Interesting, from the official docs. I haven't noticed this before.
Makes sense 🤔

https://docs.python.org/3/library/typing.html#typing.Dict

image

audit_log/headers.py Outdated Show resolved Hide resolved
@edvardm edvardm requested a review from jerr0328 July 11, 2024 15:30
edvardm added 2 commits July 16, 2024 10:59
typically it's better to specify more generic types for input parameters,
and specific types our return values. In this case changing headers
param from dict to Mapping should resolve typing issues when eg.
starlette.requests.headers.Headers instance is passed to
get_principal_from_headers()
@edvardm edvardm force-pushed the typing/generic-mapping-type-for-headers branch from e1c290d to 54239c8 Compare July 16, 2024 10:59
@edvardm edvardm merged commit 98aa39a into main Jul 16, 2024
5 checks passed
@edvardm edvardm deleted the typing/generic-mapping-type-for-headers branch July 16, 2024 11:05
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.

3 participants