Skip to content

Adds docs for TypeGuard type, #10591 #10758

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 16 commits into from
Aug 3, 2021
Merged

Adds docs for TypeGuard type, #10591 #10758

merged 16 commits into from
Aug 3, 2021

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jul 2, 2021

I am writting an article about TypeGuards and I've noticed that mypy does not document how TypeGuards work.

So, here it is!

It has several examples from the PEP itself and several custom ones.
I have tried to cover all corner-cases that I am aware of, but possibly there are other details that I've missed.

I would appreciate your feedback! 👍

Closes #10591

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! I have a couple of wording suggestions.

Also, I'm not sure the "Casts" section is the right place for these docs. "More types" is the traditional place for advanced type system features. I'm curious to hear others' opinions.

sobolevn and others added 4 commits July 9, 2021 11:27
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
@sobolevn
Copy link
Member Author

sobolevn commented Jul 9, 2021

@JelleZijlstra thanks! I thought that "casts" is the closest to type guards. I can move it, no problem.

@hauntsaninja
Copy link
Collaborator

Thank you for this! Fixed a couple small nits

@sobolevn
Copy link
Member Author

@JelleZijlstra @hauntsaninja so, should I move this to "Advanced types"? Or is "Casts" the proper place? 🙂

@hauntsaninja
Copy link
Collaborator

I'd probably put it in "More types" too, but don't feel strongly.

@sobolevn
Copy link
Member Author

Moved! 👍

@sobolevn
Copy link
Member Author

sobolevn commented Aug 3, 2021

@hauntsaninja @JelleZijlstra friendly ping 🙂

@hauntsaninja hauntsaninja merged commit 0bafbfb into python:master Aug 3, 2021
@hauntsaninja
Copy link
Collaborator

Thanks again! :-)

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.

Document TypeGuard (PEP 647)
3 participants