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

Minimal mypy update to openapy.py, adding dict type #1048

Merged
merged 2 commits into from
Nov 24, 2024

Conversation

dave42w
Copy link
Contributor

@dave42w dave42w commented Nov 22, 2024

Description

This PR just fixes the missing dict type in 3 places so that mypy warnings are reduced.

PR Checklist

Please ensure that:

  • [X ] The PR contains a descriptive title
  • [X ] The PR contains a descriptive summary of the changes
  • [X ] You build and test your changes before submitting a PR.
  • [X ] You have added relevant documentation
  • [X ] You have added relevant tests. We prefer integration tests wherever possible

Pre-Commit Instructions:

Copy link

vercel bot commented Nov 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
robyn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 23, 2024 0:28am

Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @dave42w 😄

Copy link

codspeed-hq bot commented Nov 22, 2024

CodSpeed Performance Report

Merging #1048 will not alter performance

Comparing dave42w:mypy3 (7367060) with main (9a95611)

Summary

✅ 146 untouched benchmarks

@dave42w
Copy link
Contributor Author

dave42w commented Nov 22, 2024

Hey @sansyrox

I have a fix for the mypy errors with the way we are using TypedDict for variables eg

Variable "typing.TypedDict" is not valid as a type

the fix is a new class

class str_typed_dict(TypedDict):
    key : str
    value : str

which is then used like this:

        query_params: Optional[str_typed_dict],
        request_body: Optional[str_typed_dict],
        return_annotation: Optional[str_typed_dict],

and

    def get_openapi_type(self, typed_dict: str_typed_dict) -> str:

and tested like this:

            query_param_annotations = query_params.__annotations__ if query_params is str_typed_dict else typing.get_type_hints(query_params)

All tests pass and now we have no mypy warnings in OpenApi

Are you happy for me to commit this change?

@sansyrox
Copy link
Member

@dave42w , yes ! Go ahead and thank you 😄

@dave42w
Copy link
Contributor Author

dave42w commented Nov 23, 2024

@dave42w , yes ! Go ahead and thank you 😄

Done :-)

Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

LGTM!

@sansyrox sansyrox merged commit a54c642 into sparckles:main Nov 24, 2024
60 checks passed
@dave42w dave42w deleted the mypy3 branch November 24, 2024 16:25
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