GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-40979: refactored typing.rst; same content, new sub-sections and ordering by ramalho · Pull Request #21574 · python/cpython

Conversation

@ramalho

@ramalho ramalho commented Jul 21, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Here is how I reorganized the content previously in the "Classes, functions, and decorators" section:

# Special typing primitives	
	Annotated
	Any
	Callable
	ClassVar
	Final
	ForwardRef
	Generic
	Literal
	NewType
	NoReturn
	Optional
	Protocol
	Type
	TypedDict
	TypeVar
	Union

# Generic concrete collections	
	ChainMap
	Counter
	DefaultDict
	Deque
	Dict
	FrozenSet
	List
	NamedTuple
	OrderedDict
	Set
	Tuple

# Generic ABCs	
	AbstractSet
	AsyncContextManager
	AsyncGenerator
	AsyncIterable
	AsyncIterator
	Awaitable
	ByteString
	Collection
	Container
	ContextManager
	Coroutine
	Generator
	Hashable
	io.IO
	io.BytesIO
	io.TextIO
	ItemsView
	Iterable
	Iterator
	KeysView
	Mapping
	MappingView
	MutableMapping
	MutableSequence
	MutableSet
	re.Pattern
	re.Match
	Sequence
	Sized
	ValuesView	

# Protocols	
	Reversible
	SupportsAbs
	SupportsBytes
	SupportsComplex
	SupportsFloat
	SupportsIndex
	SupportsInt
	SupportsRound	

# Aliases and constants	
	AnyStr
	Text
	TYPE_CHECKING

# Functions and decorators	
	cast
	final
	get_args
	get_origin
	get_type_hints
	no_type_check
	no_type_check_decorator
	overload
	runtime_checkable
	type_check_only

https://bugs.python.org/issue40979

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ramalho
refactored typing.rst, see Issue40979
30570c9
@ramalho
ramalho requested review from gvanrossum and ilevkivskyi as code owners July 21, 2020 00:55
@the-knights-who-say-ni

This comment has been minimized.

Sign in to view
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Jul 21, 2020
ramalho added 8 commits July 21, 2020 10:24
@ramalho
bpo-40979: undo changes to go section-by-section
1ad12cc
@ramalho
bpo-40979: 'Aliases and constants' section
c06142b
@ramalho
bpo-40979: 'Functions and decorators' section
7f5d48d
@ramalho
bpo-40979: 'Generic concrete collections' section
7fb3d72
@ramalho
bpo-40979: 'Protocols' section
b548112
@ramalho
bpo-40979: 'Special typing primitives' section
d52afa8
@ramalho
bpo-40979: 'Generic ABCs' section (initial A)
49d2a31
@ramalho
bpo-40979: 'Generic ABCs' section (initials A to H)
bb07243
@the-knights-who-say-ni the-knights-who-say-ni added CLA signed and removed CLA not signed labels Jul 21, 2020
ramalho and others added 5 commits July 21, 2020 11:51
@ramalho
bpo-40979: 'Generic ABCs' section (initials A to K)
5d7c120
@ramalho
bpo-40979: 'Generic ABCs' section (complete)
c7358d7
@ramalho
bpo-40979: reordering 'Text' entry in 'Aliases and constants'
5ab2f2f
@ramalho
bpo-40979: small markup fixes
a7528e3
@blurb-it
📜🤖 Added by blurb_it.
2e25885
@gvanrossum

gvanrossum commented Jul 21, 2020

Copy link
Copy Markdown
Member

Is this still in progress? You seem to have many commits and the tests still don't pass.

Also, I'm not so keen on alphabetizing entries. I'd rather order them from most to least important. @rhettinger Do you agree?

Finally the io and re sub-namespaces were basically a mistake. We need to document them until we decide to deprecate them, but IMO the few objects inside them should primarily be documented at the top level.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ramalho

ramalho commented Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

Thanks, @gvanrossum.

Is this still in progress?

I am done with the PR, unless changes are requested.

You seem to have many commits...

I made one huge commit with all changes, then a friend suggested it would be hard to review, so for the benefit of reviewers I made several commits working section by section. This makes it easy to verify that no content went missing during the reorganization.

and the tests still don't pass.

The last failing check was the lack of a blurb, which I added about 10 hours ago, and then I saw all checks passing. I did make some rookie mistakes before, but they are all fixed. Please let me know which tests are not passing now.

Also, I'm not so keen on alphabetizing entries. I'd rather order them from most to least important. @rhettinger Do you agree?

I used "importance" as the main criterion for ordering the sections. Within each section, I believe the user is better served with an alphabetical listing when the section is longer than a screenful. I wouldn't know how to rank the entries in Generic ABCs by importance. From an editorial perspective, orderings that are not clear to the reader are not helpful.

Finally the io and re sub-namespaces were basically a mistake. We need to document them until we decide to deprecate them, but IMO the few objects inside them should primarily be documented at the top level.

The entries for (IO, BytesIO, TextIO) and (Pattern, Match) appear together in the .rst file, but without the sub-namespace prefix. I only added a sentence in each entry about the sub-namespace, which we can simply remove when necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Jul 22, 2020

Copy link
Copy Markdown
Member

I used "importance" as the main criterion for ordering the sections. Within each section, I believe the user is better served with an alphabetical listing when the section is longer than a screenful. I wouldn't know how to rank the entries in Generic ABCs by importance. From an editorial perspective, orderings that are not clear to the reader are not helpful.

Hm; I sometimes like to read documentation starting from the top (since where else are you going to start? :-) until it gets boring, and then it's nice to have it be in some useful order. Alphabetical order may break a tie, but it was invented in order to make manual search easier. Since we have search now, that no longer applies, and we can do something more useful. (How do you organize things in your books? Hopefully not alphabetical.) If you really think it ought to be alphabetical per section, maybe we can introduce sub-sections. For example, here's a possible way to split the first two sections in parts:

# Special typing primitives

## Special types

These can be used as types in annotations and don't use `[]`.

	Any
	NoReturn

## Special forms

These can be used as types in annotations using `[]`, each having a unique syntax.

	Annotated
	Callable
	ClassVar
	Final
	Literal
	Optional
	Tuple  (Moved here! It's a special form.)
	Type
	Union

## Other special directives

These are not used in annotations.

	ForwardRef
	Generic
	NewType
	Protocol
	TypedDict
	TypeVar

# Generic concrete collections

## Corresponding to built-in types

	Dict
	FrozenSet
	List
	Set

## Corresponding to types in `collections`

	ChainMap
	Counter
	DefaultDict
	Deque
	NamedTuple
	OrderedDict

I have issues with the "generic ABCs" too: some of them are not generic, some are not abstract, and probably these should be separated by origin module, i.e. abc, collections.abc, and other modules.

I assume BytesIO is a typo for BinaryIO.

I would also separate functions and decorators into two sub-sections, and honestly there's no reason to put TYPE_CHECKING in the same section as AnyStr and Text.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rhettinger

rhettinger commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Also, I'm not so keen on alphabetizing entries. I'd rather order them from most to least important. @rhettinger Do you agree?

Yes, that makes sense.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ramalho

ramalho commented Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

Great proposal, @gvanrossum, thanks. I will follow it, but I have a couple of questions:

  1. Why is Tuple a special form from the user's perspective? As a user, I don't see it as more special than Dict. Is the rationale for treating it as a special form related to its implementation?

  2. I like the Other special directives grouping and the observation "These are not used in annotations." May we add: "They are building blocks for declaring types." ?

I have issues with the "generic ABCs" too: some of them are not generic, some are not abstract, and probably these should be separated by origin module, i.e. abc, collections.abc, and other modules.

Agreed, I will make a proposal to split that section.

I assume BytesIO is a typo for BinaryIO.

Yes.

I would also separate functions and decorators into two sub-sections, and honestly there's no reason to put TYPE_CHECKING in the same section as AnyStr and Text.

TYPE_CHECKING is the prototypical one-of. Maybe it needs a section of its own, perhaps in the top ⅓ of typing.rst, above the existing Classes, functions, and decorators section. The same section could mention the typing.type_check_only decorator, which is related.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Jul 22, 2020

Copy link
Copy Markdown
Member
  1. Why is Tuple a special form from the user's perspective? As a user, I don't see it as more special than Dict. Is the rationale for treating it as a special form related to its implementation?

No, it's special because it is variadic. You cannot create a type like that using inheritance from Generic. Also because it supports the special form Tuple[t1, ...] (with literal ... meaning ellipsis) which again cannot be done by regular generic types.

  1. I like the Other special directives grouping and the observation "These are not used in annotations." May we add: "They are building blocks for declaring types." ?

Of course. I did not mean to prescribe what you could write in the introduction of each section or subsection -- I only meant to clarify my intention for the grouping to you, so you can write something.

I would also separate functions and decorators into two sub-sections, and honestly there's no reason to put TYPE_CHECKING in the same section as AnyStr and Text.

TYPE_CHECKING is the prototypical one-of. Maybe it needs a section of its own, perhaps in the top ⅓ of typing.rst, above the existing Classes, functions, and decorators section. The same section could mention the typing.type_check_only decorator, which is related.

I am fine with a section on its own for TYPE_CHECKING -- it should just go in a section on "Constants". Many other modules have that in their docs I believe.

I am a little hesitant to document type_check_only since it does not exist at runtime, but I could not find any other docs for it except PEP 484 itself, so I guess it's useful. There are other reasons to use if TYPE_CHECKING though -- in mypy it's mostly used for imports that at runtime are delayed until they are needed for some advanced functionality, but which are needed by the type checker to be able to type-check everything (e.g. here).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ramalho added 3 commits August 1, 2020 14:07
@ramalho
Merge remote-tracking branch 'upstream/master'
006238b
@ramalho
Merge branch 'master' of github.com:ramalho/cpython
9c7b89c
@ramalho
bpo-40979: sub-sections in Special Types per #21574 (comment)
4505bbb
@gvanrossum

gvanrossum commented Aug 1, 2020

Copy link
Copy Markdown
Member

Are you going to do the proposed reordering?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gvanrossum
gvanrossum approved these changes Aug 2, 2020
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM! I think I'll merge it now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting merge label Aug 2, 2020
@gvanrossum
gvanrossum merged commit ab72fde into python:master Aug 2, 2020
@bedevere-bot

bedevere-bot commented Aug 2, 2020

Copy link
Copy Markdown

@gvanrossum: Please replace # with GH- in the commit message next time. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label Aug 2, 2020
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Aug 4, 2020
@ramalho @shihai1991
bpo-40979: refactored typing.rst; (mostly) same content, new sub-sect…
51a9b9e
…ions and ordering (python#21574)

Also added PEP 585 deprecation notes.
@gvanrossum gvanrossum added needs backport to 3.8 labels Aug 12, 2020
@miss-islington

miss-islington commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

Thanks @ramalho for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

Thanks @ramalho for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

Sorry, @ramalho and @gvanrossum, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ab72fdeb82c3ab045b480cd4bb4f928c12653ecb 3.8

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned gvanrossum Aug 12, 2020
@miss-islington

miss-islington commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

Sorry @ramalho and @gvanrossum, I had trouble checking out the 3.9 backport branch.
Please backport using cherry_picker on command line.
cherry_picker ab72fdeb82c3ab045b480cd4bb4f928c12653ecb 3.9

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Aug 12, 2020
@ramalho @gvanrossum
[3.9] bpo-40979: refactored typing.rst; (mostly) same content, new su…
23d01d3
…b-sections and ordering (pythonGH-21574)

Also added PEP 585 deprecation notes.
(cherry picked from commit ab72fde)

Co-authored-by: Luciano Ramalho <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.9 label Aug 12, 2020
@bedevere-bot

bedevere-bot commented Aug 12, 2020

Copy link
Copy Markdown

GH-21843 is a backport of this pull request to the 3.9 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gvanrossum added a commit that referenced this pull request Aug 12, 2020
@gvanrossum @ramalho
[3.9] bpo-40979: refactored typing.rst; (mostly) same content, new su…
b3ad2ca
…b-sections and ordering (GH-21574) (#21843)

Also added PEP 585 deprecation notes.

(cherry picked from commit ab72fde)

Co-authored-by: Luciano Ramalho <[email protected]>
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Aug 20, 2020
@ramalho @shihai1991
bpo-40979: refactored typing.rst; (mostly) same content, new sub-sect…
465168a
…ions and ordering (python#21574)

Also added PEP 585 deprecation notes.
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
@ramalho @xzy3-cdc
bpo-40979: refactored typing.rst; (mostly) same content, new sub-sect…
8ac5c89
…ions and ordering (python#21574)

Also added PEP 585 deprecation notes.
srittau added a commit to srittau/cpython that referenced this pull request May 13, 2021
@srittau
Remove mention of typing.io and typing.re again
65757ba
They were originally removed in pythonGH-10173 per bpo-35089, but then
readded in pythonGH-21574. Cf. bpo-38291 for decision to remove.
@srittau srittau mentioned this pull request May 13, 2021
bpo-38291: Remove mention of typing.io and typing.re again #26113
Merged
gvanrossum pushed a commit that referenced this pull request Jun 14, 2021
@srittau
bpo-38291: Remove mention of typing.io and typing.re again (GH-26113)
8a76683
They were originally removed in GH-10173 per bpo-35089, but then
readded in GH-21574. Cf. bpo-38291 for decision to remove.
@miss-islington miss-islington mentioned this pull request Jun 14, 2021
[3.10] bpo-38291: Remove mention of typing.io and typing.re again (GH-26113) #26720
Merged
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 14, 2021
@srittau @miss-islington
bpo-38291: Remove mention of typing.io and typing.re again (pythonGH-…
d2bfaa8
…26113)

They were originally removed in pythonGH-10173 per bpo-35089, but then
readded in pythonGH-21574. Cf. bpo-38291 for decision to remove.
(cherry picked from commit 8a76683)

Co-authored-by: Sebastian Rittau <[email protected]>
@miss-islington miss-islington mentioned this pull request Jun 14, 2021
[3.9] bpo-38291: Remove mention of typing.io and typing.re again (GH-26113) #26721
Merged
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 14, 2021
@srittau @miss-islington
bpo-38291: Remove mention of typing.io and typing.re again (pythonGH-…
5301eba
…26113)

They were originally removed in pythonGH-10173 per bpo-35089, but then
readded in pythonGH-21574. Cf. bpo-38291 for decision to remove.
(cherry picked from commit 8a76683)

Co-authored-by: Sebastian Rittau <[email protected]>
miss-islington added a commit that referenced this pull request Jun 14, 2021
@miss-islington @srittau
bpo-38291: Remove mention of typing.io and typing.re again (GH-26113)
fc310cb
They were originally removed in GH-10173 per bpo-35089, but then
readded in GH-21574. Cf. bpo-38291 for decision to remove.
(cherry picked from commit 8a76683)

Co-authored-by: Sebastian Rittau <[email protected]>
miss-islington added a commit that referenced this pull request Jun 14, 2021
@miss-islington @srittau
bpo-38291: Remove mention of typing.io and typing.re again (GH-26113)
7f02195
They were originally removed in GH-10173 per bpo-35089, but then
readded in GH-21574. Cf. bpo-38291 for decision to remove.
(cherry picked from commit 8a76683)

Co-authored-by: Sebastian Rittau <[email protected]>
jdevries3133 pushed a commit to jdevries3133/cpython that referenced this pull request Jun 19, 2021
@srittau @jdevries3133
bpo-38291: Remove mention of typing.io and typing.re again (pythonGH-…
6109bfa
…26113)

They were originally removed in pythonGH-10173 per bpo-35089, but then
readded in pythonGH-21574. Cf. bpo-38291 for decision to remove.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum approved these changes
@ilevkivskyi ilevkivskyi Awaiting requested review from ilevkivskyi

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gvanrossum gvanrossum

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@ramalho @the-knights-who-say-ni @gvanrossum @rhettinger @bedevere-bot @miss-islington
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.