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

Improve typing #70

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

MarekPikula
Copy link

Fixes #65

Typing:

  • make it pass mypy tests (i.e., improve type hinting) – both main module and tests
  • add mypy test to CI
  • add py.typed to setup so that other packages recognize it's typed
  • make it possible to use TypeVars for model hinting

General

CI:

  • update GitHub actions to newest revisions
  • Run linters in a separate matrix (black, flak8, mypy)

Signed-off-by: Marek Pikuła <[email protected]>
Fixes bauerji#65

- make it pass mypy tests (i.e., improve type hinting)
- add mypy test to CI
- add py.typed to setup so that other packages recognize it's typed
- enable async view function decoration (via ensure_sync() as noted on
  https://flask.palletsprojects.com/en/latest/async-await/#extensions)

Signed-off-by: Marek Pikuła <[email protected]>
Signed-off-by: Marek Pikuła <[email protected]>
Signed-off-by: Marek Pikuła <[email protected]>
Signed-off-by: Marek Pikuła <[email protected]>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@MarekPikula
Copy link
Author

Hi @bauerji, is there any chance to merge this PR?

Comment on lines 132 to 147
def _get_type_generic(hint: Any):
"""Extract type information from bound TypeVar or Type[TypeVar]."""
if isinstance(hint, TypeVar):
assert (
getattr(hint, "__bound__", None) is not None
), "If using TypeVar, you need to specify bound model."
return getattr(hint, "__bound__")

args = get_args(hint)
if len(args) > 0 and isinstance(args[0], TypeVar):
assert (
getattr(args[0], "__bound__", None) is not None
), "If using TypeVar, you need to specify bound model."
return getattr(args[0], "__bound__")

return hint
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please add tests to cover this? Also would be nice to mention that in docs 🙏

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing 🙂

Copy link
Author

Choose a reason for hiding this comment

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

Done. Let me know if it's enough.

Copy link
Author

Choose a reason for hiding this comment

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

Hi, any news regarding the review? Is there anything I could do to move forward this PR?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@MarekPikula MarekPikula requested a review from bauerji June 4, 2023 13:57
@MarekPikula
Copy link
Author

MarekPikula commented Jun 15, 2024

Hi @bauerji, any news regarding this PR? I've made the changes you requested some time ago. Let me know what can I do to move this PR forward.

If you give me a green light for the recent changes, I'll rebase this PR on the main branch.

@kouk
Copy link

kouk commented Dec 10, 2024

@bauerji I'm also interested in getting this merged. Could you let us know if there's something we can do to help? thank you

@kouk
Copy link

kouk commented Dec 10, 2024

@MarekPikula I resolved the conflicts between this branch and the current repo HEAD here: https://github.com/bauerji/flask-pydantic/compare/master...kouk:flask-pydantic:improve_typing?expand=1

@kouk kouk mentioned this pull request Dec 10, 2024
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.

add py.typed marker indicating provision of inlined types
3 participants