This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Expand documentation about type aliases and NewType in the typing module
Type: Stage:
Components: Documentation Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, gvanrossum, levkivskyi, michael0x2a
Priority: normal Keywords: patch

Created on 2016-07-28 17:29 by michael0x2a, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
document_newtype.patch michael0x2a, 2016-07-28 17:29 review
document_newtype_rev2.patch michael0x2a, 2016-07-29 21:09 review
Messages (7)
msg271572 - (view) Author: Michael Lee (michael0x2a) * Date: 2016-07-28 17:29
This is a patch to update the documentation on the typing module. It expands the section on type aliases and adds a section on [NewType][0].

Since support for NewType was [recently added][1] to mypy, it seemed like a prudent time to update the docs to describe this new feature.

The section on type aliases was mainly expanded because the distinction between type aliases and NewType could be potentially confusing, so adding extra clarification seemed like a good idea.

  [0]: https://www.python.org/dev/peps/pep-0484/#newtype-helper-function
  [1]: https://github.com/python/mypy/pull/1939
msg271588 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2016-07-28 22:14
Added two small comments to the review.
msg271642 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2016-07-29 19:40
> Should I edit the patch to include a sentence or two describing this
> distinction, just remove the word "almost", or do something else?

I think the best way is to remove the "almost" and briefly explain that you cannot subclass types returned by NewType.
msg271648 - (view) Author: Michael Lee (michael0x2a) * Date: 2016-07-29 21:09
Ok, here's revision 2 of my patch, after applying the changes from the last round of feedback.
msg271650 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2016-07-29 21:25
I have only one optional comment on the second revision.
msg271655 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-07-29 22:40
Thanks! Should go live later today.
msg271656 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-07-29 22:42
Mercurial revs: fd0dce6d33e7, 15a35a8da24b, 4ecea1ea11bf, 4ecea1ea11bf.
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71831
2016-07-29 22:42:45gvanrossumsetmessages: + msg271656
2016-07-29 22:40:21gvanrossumsetstatus: open -> closed
resolution: fixed
messages: + msg271655
2016-07-29 21:25:54levkivskyisetnosy: + gvanrossum
messages: + msg271650
2016-07-29 21:09:27michael0x2asetfiles: + document_newtype_rev2.patch

messages: + msg271648
2016-07-29 19:40:40levkivskyisetmessages: + msg271642
2016-07-28 22:14:08levkivskyisetmessages: + msg271588
2016-07-28 22:12:17levkivskyisetnosy: + levkivskyi
2016-07-28 17:29:04michael0x2acreate