Repository navigation
Document PEP 585, 563, 604 and more. - #9763
Merged
Merged
Conversation
added 2 commits
November 27, 2020 16:23
Fixes python#8629, fixes python#8523 This creates a new page to document issues arising from discrepancies between the runtime and annotations. I felt this was better, rather than force-fitting things into existing pages and "common issues", for instance, it prevents us from having to explain PEP 563 in several different places. I do still list the runtime errors you'd get in the "common issues" page to preserve SEO :-) "String literal types", "Class name forward references", and "Import cycles" are basically the same as where they were copied over from. This also factors out the documentation of PEP 604 that I promised when merging that PR (it seemed pretty verbose, particularly for the "kinds of types" page). It's also a good place to document PEP 613, when we get around to supporting that.
Closed
5 of 6 tasks
JukkaL
reviewed
Dec 11, 2020
| three tools at our disposal: | ||
|
|
||
| * For Python 3.7 through 3.9, use of ``from __future__ import annotations`` | ||
| (:pep:`563`), made the default in Python 3.10 and later |
Collaborator
There was a problem hiding this comment.
Nit: Since 3.10 is not out yet, this would be better written as "... will be the default in Python 3.10 and later".
|
|
||
| Python 3.5.1 and below don't have :py:data:`~typing.TYPE_CHECKING`. An | ||
| alternative is to define a constant named ``MYPY`` that has the value | ||
| ``False`` at runtime. Mypy considers it to be ``True`` when type checking. |
Collaborator
There was a problem hiding this comment.
Maybe add a short example of how this works here?
| Using X | Y syntax for Unions | ||
| ----------------------------- | ||
|
|
||
| Starting with Python 3.10 (:pep:`604`), you can spell union types as ``x: int | |
Collaborator
There was a problem hiding this comment.
Nit: "... you will be able to spell", since Python 3.10 is not out yet.
Collaborator
Author
|
Thanks, made changes everywhere that I marked a conversation as resolved. The two things I haven't done are:
|
JukkaL
approved these changes
Jan 6, 2021
JukkaL
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the updates! Looks good now. I agree with your reasoning, and other changes I proposed aren't important.
Closed
ilevkivskyi
pushed a commit
that referenced
this pull request
Jan 19, 2021
Fixes #8629, fixes #8523. This creates a new page to document issues arising from discrepancies between the runtime and annotations. I felt this was better, rather than force-fitting things into existing pages and "common issues", for instance, it prevents us from having to explain PEP 563 in several different places. I do still list the runtime errors you'd get in the "common issues" page to preserve SEO :-) "String literal types", "Class name forward references", and "Import cycles" are basically the same as where they were copied over from. This also factors out the documentation of PEP 604 that I promised when merging that PR (it seemed pretty verbose, particularly for the "kinds of types" page). It's also a good place to document PEP 613, when we get around to supporting that. Resolves #9856. Co-authored-by: hauntsaninja <>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8629, fixes #8523
This creates a new page to document issues arising from discrepancies
between the runtime and annotations. I felt this was better, rather than
force-fitting things into existing pages and "common issues", for
instance, it prevents us from having to explain PEP 563 in several
different places.
I do still list the runtime errors you'd get in the "common issues" page
to preserve SEO :-)
"String literal types", "Class name forward references", and "Import
cycles" are basically the same as where they were copied over from.
This also factors out the documentation of PEP 604 that I promised when
merging that PR (it seemed pretty verbose, particularly for the "kinds
of types" page). It's also a good place to document PEP 613, when we get
around to supporting that.