updates
This commit is contained in:
parent
a27505a58c
commit
d5e650c976
1 changed files with 18 additions and 19 deletions
|
@ -1,11 +1,10 @@
|
|||
#+title: Python Typing
|
||||
#+LINK: pep https://www.python.org/dev/peps/pep-%s/
|
||||
|
||||
Python does not require nor enforce strict typing, and instead takes a dynamic
|
||||
approach using [[file:20201008164244-duck_typing.org][Duck Typing]].
|
||||
|
||||
[[file:20201010185815-gradual_typing.org][Gradual Typing]] support for Python is provided via type hints as described in
|
||||
[[pep:0484][PEP-484]] (which covers [[file:20201009010657-nominal_typing.org][Nominal Typing]]) and expanded upon in [[pep:0544][PEP-544]] (which covers
|
||||
[[https://www.python.org/dev/peps/pep-0484/][PEP-484]] (which covers [[file:20201009010657-nominal_typing.org][Nominal Typing]]) and expanded upon in [[https://www.python.org/dev/peps/pep-0544/][PEP-544]] (which covers
|
||||
[[file:20201008164835-structural_typing.org][Structural Typing]]).
|
||||
|
||||
Variables, function arguments, and return values can have their types annotated,
|
||||
|
@ -24,21 +23,21 @@ program correctness.
|
|||
- Type hints do not guarantee purity.
|
||||
- Type hints are not checked at run-time.
|
||||
* Fun facts
|
||||
- Per [[pep:0285][PEP-285]], Python's =boolean= inherits from =int=, hence =True + True = 2=.
|
||||
- Per [[https://www.python.org/dev/peps/pep-0285/][PEP-285]], Python's =boolean= inherits from =int=, hence =True + True = 2=.
|
||||
* Relevant PEPs
|
||||
- [[pep:3107][PEP 3107 -- Function Annotations]]
|
||||
- [[pep:0482][PEP 482 -- Literature Overview for Type Hints]]
|
||||
- [[pep:0483][PEP 483 -- The Theory of Type Hints]]
|
||||
- [[pep:0484][PEP 484 -- Type Hints]]
|
||||
- [[pep:0526][PEP 526 -- Syntax for Variable Annotations]]
|
||||
- [[pep:0544][PEP 544 -- Protocols: Structural subtyping (static duck typing)]]
|
||||
- [[pep:0557][PEP 557 -- Data Classes]]
|
||||
- [[pep:0560][PEP 560 -- Core support for typing module and generic types]]
|
||||
- [[pep:0561][PEP 561 -- Distributing and Packaging Type Information]]
|
||||
- [[pep:0563][PEP 563 -- Postponed Evaluation of Annotations]]
|
||||
- [[pep:0585][PEP 585 -- Type Hinting Generics In Standard Collections]]
|
||||
- [[pep:0586][PEP 586 -- Literal Types]]
|
||||
- [[pep:0589][PEP 589 -- TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys]]
|
||||
- [[pep:0591][PEP 591 -- Adding a final qualifier to typing]]
|
||||
- [[pep:0604][PEP 604 -- Allow writing union types as X | Y]]
|
||||
- [[pep:0613][PEP 613 -- Explicit Type Aliases]]
|
||||
- [[https://www.python.org/dev/peps/pep-3107/][PEP 3107 -- Function Annotations]]
|
||||
- [[https://www.python.org/dev/peps/pep-0482/][PEP 482 -- Literature Overview for Type Hints]]
|
||||
- [[https://www.python.org/dev/peps/pep-0483/][PEP 483 -- The Theory of Type Hints]]
|
||||
- [[https://www.python.org/dev/peps/pep-0484/][PEP 484 -- Type Hints]]
|
||||
- [[https://www.python.org/dev/peps/pep-0526/][PEP 526 -- Syntax for Variable Annotations]]
|
||||
- [[https://www.python.org/dev/peps/pep-0544/][PEP 544 -- Protocols: Structural subtyping (static duck typing)]]
|
||||
- [[https://www.python.org/dev/peps/pep-0557/][PEP 557 -- Data Classes]]
|
||||
- [[https://www.python.org/dev/peps/pep-0560/][PEP 560 -- Core support for typing module and generic types]]
|
||||
- [[https://www.python.org/dev/peps/pep-0561/][PEP 561 -- Distributing and Packaging Type Information]]
|
||||
- [[https://www.python.org/dev/peps/pep-0563/][PEP 563 -- Postponed Evaluation of Annotations]]
|
||||
- [[https://www.python.org/dev/peps/pep-0585/][PEP 585 -- Type Hinting Generics In Standard Collections]]
|
||||
- [[https://www.python.org/dev/peps/pep-0586/][PEP 586 -- Literal Types]]
|
||||
- [[https://www.python.org/dev/peps/pep-0589/][PEP 589 -- TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys]]
|
||||
- [[https://www.python.org/dev/peps/pep-0591/][PEP 591 -- Adding a final qualifier to typing]]
|
||||
- [[https://www.python.org/dev/peps/pep-0604/][PEP 604 -- Allow writing union types as X | Y]]
|
||||
- [[https://www.python.org/dev/peps/pep-0613/][PEP 613 -- Explicit Type Aliases]]
|
||||
|
|
Loading…
Reference in a new issue