Skip to content

we can use recent typing for stub file or pure type hint #202

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

Merged
merged 1 commit into from
Jul 31, 2022

Conversation

PrettyWood
Copy link
Collaborator

@PrettyWood PrettyWood commented Jul 29, 2022

As discussed on twitter it works great to already use new typing in quotes as long as it doesn't need to be interpreted (obviously)
So we can at least use that in stub file or in function signatures but not on TypedDict, BaseModel, ...

I tried with python 3.8 and it works perfectly (with pyright, in vscode and pycharm)

@PrettyWood PrettyWood marked this pull request as ready for review July 29, 2022 19:45
@samuelcolvin
Copy link
Member

👍 LGTM

@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #202 (58f6dd2) into main (4faedfe) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #202   +/-   ##
=======================================
  Coverage   98.03%   98.03%           
=======================================
  Files          46       46           
  Lines        4539     4539           
  Branches       32       32           
=======================================
  Hits         4450     4450           
  Misses         89       89           

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 4faedfe...58f6dd2. Read the comment docs.

@samuelcolvin
Copy link
Member

just to check, did you try mypy too? I know mypy can't actually evaluate our schema because it's recursive, hence why we're using pyright, but mypy could analyse this file.

@PrettyWood
Copy link
Collaborator Author

Yep mypy understand everything as well. It's exactly like pyright (except it doesn't understand the schema indeed)

@samuelcolvin samuelcolvin merged commit 2e6d95b into pydantic:main Jul 31, 2022
@samuelcolvin
Copy link
Member

thanks.

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