Skip to content
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

Add the typing spec #1517

Merged
merged 7 commits into from
Dec 11, 2023
Merged

Add the typing spec #1517

merged 7 commits into from
Dec 11, 2023

Conversation

JelleZijlstra
Copy link
Member

Copied over from https://github.com/JelleZijlstra/typing-spec

The text largely derives from the typing PEPs, though I added some
material. The organization is based on an outline by @erictraut.
@rchen152 and @Daverball made contributions to the text.

This was previously discussed on https://discuss.python.org/t/proposed-initial-typing-spec/39389. I'll submit an issue to the Typing Council to request its imprimatur.

Copied over from https://github.com/JelleZijlstra/typing-spec

The text largely derives from the typing PEPs, though I added some
material. The organization is based on an outline by @erictraut.
@rchen152 and @Daverball made contributions to the text.
@JelleZijlstra JelleZijlstra added the Typing Council decision Needs to be approved by the Typing Council. Do not merge until approved. label Nov 29, 2023
docs/spec/dataclasses.rst Show resolved Hide resolved
docs/spec/directives.rst Outdated Show resolved Hide resolved
docs/spec/typeddict.rst Outdated Show resolved Hide resolved
@JelleZijlstra
Copy link
Member Author

Addressed @sobolevn's comments and added @deprecated from PEP-702.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

One minor thing for later is we have a bunch of links to PEPs that should maybe become internal links

@JelleZijlstra
Copy link
Member Author

@hauntsaninja I agree, but won't have time right now to fix that. As you say, let's leave it for later.


(Originally specified in :pep:`702`.)

The :py:func:`warnings.deprecated`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The :py:func:`warnings.deprecated`
The :class:`warnings.deprecated`

As this is now implemented as a class?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes makes sense, it isn't auto-generated docs

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

I'm not sure how precise a review you're expecting. I'm okay if this goes in right away (we can iterate on everything), but here are some thoughts that came up when I skimmed it.

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
Copy link
Member

Choose a reason for hiding this comment

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

Why is this here? I went into this directory and typed make venv but it complained about a missing conf.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, probably a holdover from when it was in its own repo. I'll get rid of it. (You should make in the parent directory, which includes this spec and the other typing docs.)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I figured that out eventually. It's a bit weird how clicking on the Table of Contents header at the top of the sidebar takes you to the global ToC, not the Spec ToC, even though there is no "Next topic" linked from spec/historical.html, the last topic in Spec (so I would expect that the ToC link would go to the Spec ToC). But that's a very minor detail at this point, and probably some Sphinx oddity.

@@ -0,0 +1,95 @@
Type system concepts
Copy link
Member

Choose a reason for hiding this comment

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

This feels like a grab-bag section, and it's oddly placed at the start of the document (why start with unions, when nothing else has been described yet)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This comes from Eric's outline in https://discuss.python.org/t/proposed-initial-typing-spec/39389/4, but I omitted the sections for which we don't have any text yet. I'm open to reorganizing this, but we can do that later too.

Copy link
Member

Choose a reason for hiding this comment

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

Later is fine.

@@ -0,0 +1,291 @@
.. _historical:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add from __future__ import annotations to this page? I was reminded of it in the section about forward references. I think it's within the scope of the typing spec, since it changes semantics: even if you don't use runtime introspection, enabling it changes what gets accepted.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure it does; shouldn't type checkers infer the same types with and without the future import? Obviously the future import affects the runtime behavior, but this spec doesn't need to describe that.

Copy link
Member

Choose a reason for hiding this comment

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

Huh, I suppose. Does the spec not describe any runtime behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does in a few cases, but in principle I think it shouldn't. docs.python.org describes how Python the language works; this spec should only describe the semantics of the type system.

@JelleZijlstra
Copy link
Member Author

I'm not sure how precise a review you're expecting. I'm okay if this goes in right away (we can iterate on everything), but here are some thoughts that came up when I skimmed it.

Thanks! I think a general review is enough; this text is so big that we can't hope to get it all right, and I primarily want this in so we can start iterating on it and improving it.

@JelleZijlstra JelleZijlstra merged commit 7117775 into python:master Dec 11, 2023
3 checks passed
@JelleZijlstra JelleZijlstra deleted the spec branch December 11, 2023 04:27
@JelleZijlstra JelleZijlstra restored the spec branch September 10, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing Council decision Needs to be approved by the Typing Council. Do not merge until approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants