Skip to content

Initial full TOC structure for typing docs content #919

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 2 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Reading the docs
=================

The live documentation for Python's static typing can be found at
[typing.readthedocs.io](https://typing.readthedocs.io/).
`typing.readthedocs.io <https://typing.readthedocs.io/>`_.

Building the docs
=================
Expand Down
9 changes: 6 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ Static Typing with Python
:maxdepth: 2
:caption: Contents:

typing Module Documentation <https://docs.python.org/3/library/typing.html>
source/libraries
source/stubs
source/introduction

.. toctree::
:maxdepth: 3

source/reference


Indices and tables
Expand Down
68 changes: 68 additions & 0 deletions docs/source/annotations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
****************
Type Annotations
****************

Functions
=========

Parameters
----------

Asynchronous Functions
----------------------

Generators
----------

Lambdas
-------


Classes
=======

Overloads and Overrides
Copy link
Collaborator

Choose a reason for hiding this comment

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

Overloads feels more functions-y, is overrides meant to talk about Liskov Substitution Principle? Potentially worth separating

-----------------------

Instance vs. Class Attributes
-----------------------------

Final attributes
----------------

Abstract base classes
---------------------


Globals
=======


Attributes
==========


Locals
======

Empty Containers
----------------


Runtime Considerations
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's useful, I recently rewrote mypy's documentation for this: https://mypy.readthedocs.io/en/latest/runtime_troubles.html

======================

Comment vs. Inline Support
--------------------------

Forward References
------------------

Generic types that don't implement `__getitem__`
------------------------------------------------

Conditioning on static type checking
------------------------------------

from `__future__` import annotations
------------------------------------
3 changes: 3 additions & 0 deletions docs/source/basics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**********
The Basics
Copy link
Collaborator

Choose a reason for hiding this comment

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

mypy's cheat sheet (https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html) is the most visited page in mypy's documentation, I'm assuming this will be something similar?

**********
12 changes: 12 additions & 0 deletions docs/source/dependencies.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**************************
Libraries and Dependencies
**************************

:doc:`libraries`

Typeshed
========


Placeholder Stubs
=================
23 changes: 23 additions & 0 deletions docs/source/faq.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**************************
Frequently Asked Questions
**************************


Why Types?
==========


Unsupported Python Features
===========================


Common Errors
=============


Typing PEPs
===========


Relevant Talks and Resources
============================
28 changes: 28 additions & 0 deletions docs/source/inference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**************
Type Inference
**************

Rules for local inference
=========================

Explicit vs. Implicit Local Types
---------------------------------

Changing Types
==============

Asserts
-------

Casts
-----

Type Guards
-----------


Protocols and Duck Typing
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this is where we cover int <: float <: complex and the other special cases?

=========================

Callback Protocols
------------------
41 changes: 41 additions & 0 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
*******************************
Introduction to Types in Python
*******************************


Background
==========

How to read type annotations
----------------------------

When and why types are useful
-----------------------------


Gradual Typing: Static Types in a Dynamic Language
==================================================

Opt-in type checking
--------------------

Type stubs
----------

:doc:`stubs`

Strategies for increasing coverage
----------------------------------


Getting Started
===============

Python type checkers
--------------------

How to annotate an existing codebase
------------------------------------

Typeshed
--------
2 changes: 2 additions & 0 deletions docs/source/libraries.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _libraries:

***********************
Typing Python Libraries
***********************
Expand Down
15 changes: 15 additions & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*********************
Type System Reference
*********************

.. toctree::
:maxdepth: 2
:caption: Contents:

basics
type_system
annotations
inference
type_compatibility
dependencies
faq
17 changes: 17 additions & 0 deletions docs/source/type_compatibility.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
******************
Type Compatibility
******************


The Class Hierarchy
===================

Mutable Containers
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might make sense to move the section to where we introduce generics, since it's hard to have any discussion of variance without examples.

------------------

Comparing Callables: Covariance and Contravariance
--------------------------------------------------


Metaclasses
===========
58 changes: 58 additions & 0 deletions docs/source/type_system.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
***************
The Type System
***************

Built-in Types
==============

`typing Module Documentation <https://docs.python.org/3/library/typing.html>`__

Built-in Primitives
-------------------

Built-in operators
------------------

Advanced Types
--------------
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing Literal goes in here?



Simple User-Defined Types
=========================


Type Aliases
============

Recursive Aliases
-----------------


Data Structures
===============

Typed Dictionary
----------------

Dataclass
---------


Generic Types
=============


Type Variables
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe type variables should be introduced before generic types?

==============

TypeVar
-------

Variadics
---------

ParamSpec
^^^^^^^^^

TypeVarTuple
^^^^^^^^^^^^