Commit Graph

247 Commits

Author SHA1 Message Date
Anthony Sottile b7daabd711 Improve version added references in `typing` module docs (GH-13457) 2019-06-02 01:13:25 +01:00
Ivan Levkivskyi 4c23aff065
bpo-29262: Add get_origin() and get_args() introspection helpers to typing (GH-13685)
This is an old feature request that appears from time to time. After a year of experimenting with various introspection capabilities in `typing_inspect` on PyPI, I propose to add these two most commonly used functions: `get_origin()` and `get_args()`. These are essentially thin public wrappers around private APIs: `__origin__` and `__args__`.

As discussed in the issue and on the typing tracker, exposing some public helpers instead of `__origin__` and `__args__` directly will give us more flexibility if we will decide to update the internal representation, while still maintaining backwards compatibility.

The implementation is very simple an is essentially a copy from `typing_inspect` with one exception: `ClassVar` was special-cased in `typing_inspect`, but I think this special-casing doesn't really help and only makes things more complicated.
2019-05-31 00:10:07 +01:00
Ivan Levkivskyi 74d7f76e2c
bpo-37058: PEP 544: Add Protocol to typing module (GH-13585)
I tried to get rid of the `_ProtocolMeta`, but unfortunately it didn'y work. My idea to return a generic alias from `@runtime_checkable` made runtime protocols unpickleable. I am not sure what is worse (a custom metaclass or having some classes unpickleable), so I decided to stick with the status quo (since there were no complains so far). So essentially this is a copy of the implementation in `typing_extensions` with two modifications:
* Rename `@runtime` to `@runtime_checkable` (plus corresponding updates).
* Allow protocols that extend `collections.abc.Iterable` etc.
2019-05-28 08:40:15 +01:00
Ivan Levkivskyi 135c6a56e5
bpo-37049: PEP 589: Add TypedDict to typing module (GH-13573)
The implementation is straightforward and essentially is just copied from `typing_extensions`.
2019-05-26 09:39:24 +01:00
Ivan Levkivskyi b891c465bb
bpo-37046: PEP 586: Add Literal to typing module (#13572)
The implementation is straightforward and essentially is just copied from `typing_extensions`.
2019-05-26 09:37:48 +01:00
Ivan Levkivskyi f367242d10
bpo-37045: PEP 591: Add final qualifiers to typing module (GH-13571)
The implementation is straightforward, it just mimics `ClassVar` (since the latter is also a name/access qualifier, not really a type). Also it is essentially copied from `typing_extensions`.
2019-05-26 09:37:07 +01:00
Paul Dagnelie 4c7a46eb3c bpo-36972: Add SupportsIndex (GH-13448)
In order to support typing checks calling hex(), oct() and bin() on user-defined classes, a SupportIndex protocol is required. The ability to check these at runtime would be good to add for completeness sake. This is pretty much just a copy of SupportsInt with the names tweaked.
2019-05-22 15:23:01 +01:00
cocoatomo 9941f963fe Fix wrong indentation of a paragraph in documentation (GH-12868)
This paragraph doesn't seem to be a part of code, but merged into previous code block.
2019-04-18 01:54:51 +01:00
Sebastian Rittau 1e8295402b bpo-35581: Document @typing.type_check_only (GH-11312) 2019-04-12 15:33:40 -07:00
Raymond Hettinger f7b57df0c0 bpo-36320: Switch typing.NamedTuple from OrderedDict to regular dict (GH-12396)
Also,  deprecate the *_field_types* attributes which duplicated the information in *\__annotations__*.


https://bugs.python.org/issue36320
2019-03-18 09:53:56 -07:00
Raymond Hettinger 9c68543f02 Update the seealso entries for namedtuple() (GH-12373)
* Replace external recipe link with a link to the dataclasses module.

* Highlight the class definition syntax for typing.NamedTuple
  and add an example for clarity.
2019-03-16 12:53:23 -07:00
Jack Wilsdon 903567e4f5 Fix the versionadded info for typing.NoReturn (GH-11880)
The earliest version that `typing.NoReturn` appears in is [3.5.4rc1](https://docs.python.org/3/whatsnew/changelog.html#python-3-5-4-release-candidate-1)
2019-02-15 11:20:28 -08:00
Ville Skyttä 31ec52a9af bpo-35631: Improve typing docs wrt abstract/concrete collection types (GH-11396)
https://bugs.python.org/issue35631
2019-01-04 14:14:32 +00:00
Boštjan Mejak 284b787612 Add 2 missing commas (GH-10698) 2018-12-23 08:45:51 -08:00
Ismo Toijala 68b56d02ef bpo-35341: Add generic version of OrderedDict to typing (GH-10850) 2018-12-02 15:53:14 +00:00
Sebastian Rittau c8a8d6b347 bpo-35089: Don't mention typing.io and typing.re (GH-10173)
https://bugs.python.org/issue35089
2018-10-28 16:03:29 +00:00
Stéphane Wirtel 12e696b4f0 bpo-35042: Use the :pep: role where a PEP is specified (#10036) 2018-10-26 15:58:26 -07:00
Stéphane Wirtel e483f02423 bpo-35044, doc: Use the :exc: role for the exceptions (GH-10037) 2018-10-26 12:52:11 +02:00
Michael Lee 130717fe58 Clarify that Type[SomeTypeVar] is legal (#9585)
Currently, the docs state that when doing `Type[X]`, X is only allowed to
be a class, a union of classes, and Any. This pull request amends
that sentence to clarify X may also be a typevar (or a union involving
classes, Any, and TypeVars).
2018-09-26 16:13:28 +01:00
Ville Skyttä 336c945858 bpo-34336: Don't promote possibility to leave out typing.Optional (#8677) 2018-08-05 17:38:04 +01:00
Ivan Levkivskyi 6e413f4327
Document typing.NoReturn (GH-7107) 2018-05-24 21:33:55 -07:00
Ivan Levkivskyi f65e31fee3
bpo-28556: Don't simplify unions at runtime (GH-6841) 2018-05-18 16:00:38 -07:00
Travis DePrato b7b493e2fb Add AsyncContextManager to typing module documentation. (GH-6822) 2018-05-14 18:14:07 -04:00
Sebastian Rittau c3e070f849 bpo-32284: Fix documentation of BinaryIO and TextIO (#4832) 2017-12-13 10:39:55 +02:00
Ivan Levkivskyi 0cd2e81bea bpo-29879: Update typing documentation. (GH-4573)
- Add "version added: 3.5.2" note where it was missing.
- Remove the mention that Reversible is new in 3.5.2
2017-11-26 14:23:02 -08:00
Éric Araujo 03b9537dc5 bpo-31567: more decorator markup fixes in docs (GH-3959) (#3966) 2017-10-12 12:28:55 -04:00
topper-123 039b25d8fd bpo-31564: Update typing documentation (GH-3696)
Mention that ``NewType`` can derive from another ``NewType``.
2017-09-23 19:37:48 -07:00
khyox 6580c19bbb bpo-30619: Clarify typing.Union documentation (GH-2326)
When a class and its subclass are present, the latter is skipped.
2017-06-22 06:14:57 -07:00
Mathias Rav 87c07fe9d9 bpo-29974: Improve typing.TYPE_CHECKING example (GH-982)
* Fix PEP 8 (SomeType instead of some_type)
* Add a function parameter annotation
* Explain, using wording from PEP 484 and PEP 526,
  why one annotation is in quotes and another is not.

Suggested by Ivan Levkevskyi.
2017-04-26 13:49:45 +03:00
Jelle Zijlstra 45d22c256b Improvements to typing documentation (#967)
Documents a few omitted classes and adds NamedTuple methods.
2017-04-08 19:09:14 +03:00
Mariatta 36da1c3589 bpo-29481: add versionadded 3.6.1 to typing.Deque docs (#107) 2017-02-15 11:37:18 -08:00
Berker Peksag 5a001eea5b Issue #29198: Merge from 3.5 2017-02-04 09:34:48 +03:00
Berker Peksag 5702fb7b4d Issue #29198: Fix indentation and markup in typing.rst
Patch by Jelle Zijlstra.
2017-02-04 09:34:16 +03:00
Berker Peksag 14169b2a89 Issue #29198: Merge from 3.5 2017-02-04 09:18:42 +03:00
Berker Peksag 38962a6fe2 Issue #29198: Document typing.AsyncGenerator
Patch by Jelle Zijlstra.
2017-02-04 09:18:11 +03:00
Raymond Hettinger e53bd8e2d0 Issue 29310: Document typing.NamedTuple default argument syntax 2017-01-28 20:16:40 -08:00
Ned Deily 67c1cb2008 Issue #29316: Restore the provisional status of typing module and add
corresponding note to documentation. Patch by Ivan L.
2017-01-20 10:13:23 -05:00
Raymond Hettinger e12c313f5e merge 2017-01-16 22:43:43 -08:00
Raymond Hettinger 80490525e0 Issue #29011: Fix an important omission by adding Deque to the typing module. 2017-01-16 22:42:37 -08:00
Berker Peksag 4931122de8 Add missing square bracket in typing.get_type_hints() 2016-11-25 20:10:07 +03:00
Guido van Rossum a860286eab Issue #28773: Add typing.FrozenSet docs. (Manuel Krebber) 2016-11-24 11:56:00 -08:00
Berker Peksag 861b685941 Merge from 3.5 2016-11-25 20:10:30 +03:00
Guido van Rossum b3c5dc912d Issue #28773: Add typing.FrozenSet docs. (Manuel Krebber) (3.5->3.6) 2016-11-24 11:56:40 -08:00
Guido van Rossum 2d6c17936e Issue 28644: Document recent changes in typing.py (Ivan L) (3.5->3.6) 2016-11-11 15:57:09 -08:00
Guido van Rossum ae08687c3b Issue 28644: Document recent changes in typing.py (Ivan L) 2016-11-11 15:54:04 -08:00
Guido van Rossum 5ec24314cd Issue #28107: Update typing module documentation for NamedTuple (Ivan) 2016-10-25 09:53:11 -07:00
Serhiy Storchaka 989db5c880 Issue #19795: Mark up None as literal text. 2016-10-19 16:37:13 +03:00
Serhiy Storchaka ecf41da83e Issue #19795: Mark up None as literal text. 2016-10-19 16:29:26 +03:00
Guido van Rossum 7b2aa2e87c Adjust ClassVar example to use pre-PEP-526 syntax. (Issue #28388) 2016-10-08 20:12:54 -07:00
Guido van Rossum b258db9840 Issue #28388: update typing module documentation. (merge 3.5->3.6) 2016-10-08 20:09:56 -07:00
Guido van Rossum deed0c797c Issue #28388: update typing module documentation. 2016-10-08 20:06:56 -07:00
Guido van Rossum 56ff5f7298 Issue #26141: Update docs for typing.py. Ivan Levkivskyi. (Backport from the 3.6 version) 2016-09-10 19:03:22 -07:00
Guido van Rossum 446e168202 Issue #26141: Update docs for typing.py. Ivan Levkivskyi. 2016-09-10 18:54:14 -07:00
Guido van Rossum f7f8299967 Issue #28073: Improve wording around None. Michael Lee. (3.5->3.6) 2016-09-10 18:49:34 -07:00
Guido van Rossum 1816dfe65f Issue #28073: Improve wording around None. Michael Lee. 2016-09-10 18:49:14 -07:00
Guido van Rossum 922175922c Issue #28049: Add documentation for typing.Awaitable and friends.
By Michael Lee.
2016-09-09 11:46:34 -07:00
Guido van Rossum e848cd7605 Issue #27905: Docs for typing.Type[C], by Michael Lee. 2016-09-06 21:12:44 -07:00
Guido van Rossum 1de1a6a2dc Issue #27905: Docs for typing.Type[C], by Michael Lee. (Merge 3.5->3.6) 2016-09-06 21:13:15 -07:00
Vinay Sajip dd917f84e3 Closes #27904: Improved logging statements to defer formatting until needed. 2016-08-31 08:22:29 +01:00
Guido van Rossum b09b3f7ab9 Add docs for typing.AnyStr and typing.Text. By Michael Lee. (Merge 3.5->3.6) 2016-08-15 15:08:11 -07:00
Guido van Rossum aa9560c633 Add docs for typing.AnyStr and typing.Text. By Michael Lee. 2016-08-15 15:06:38 -07:00
Berker Peksag 1107f09bfc Merge from 3.5 2016-08-08 13:35:27 +03:00
Berker Peksag 08d85ee78d Fix use of default reST role 2016-08-08 13:34:49 +03:00
Guido van Rossum 3cc38327b6 Better docs for typing.Any by Michael Lee. Fixes issue #27688. (Merge 3.5->3.6) 2016-08-06 13:48:10 -07:00
Guido van Rossum abfe28b012 Better docs for typing.Any by Michael Lee. Fixes issue #27688. 2016-08-06 13:46:48 -07:00
Guido van Rossum b6337a1145 Add typing.Generator docs, by Michael Lee. (Merge 3.5->3.6) 2016-08-05 12:57:38 -07:00
Guido van Rossum b858af61b9 Add typing.Generator docs, by Michael Lee. 2016-08-05 12:56:09 -07:00
Berker Peksag f6daa690e4 Merge from 3.5 2016-07-30 03:48:12 +03:00
Berker Peksag fa95068081 Silence another "default role used" warning in typing.rst
This should make ware-docs green again.
2016-07-30 03:47:52 +03:00
Guido van Rossum a9333b1207 Fix whitespace. 2016-07-29 15:41:35 -07:00
Guido van Rossum c301cbf445 Fix whitespace. 2016-07-29 15:41:17 -07:00
Guido van Rossum e608709675 Expand documentation about type aliases and NewType in the typing module (merge 3.5 -> 3.6).
By Michael Lee.
2016-07-29 15:39:36 -07:00
Guido van Rossum 342e800e97 Expand documentation about type aliases and NewType in the typing module.
By Michael Lee.
2016-07-29 15:38:14 -07:00
Guido van Rossum 7acc3486d6 Fix issue #27402: example for typing did not type-check. (Merge 3.5->3.6) 2016-06-28 10:12:22 -07:00
Guido van Rossum 457509826e Fix issue #27402: example for typing did not type-check. 2016-06-28 10:08:17 -07:00
Terry Jan Reedy 4da945f361 Merge Issue #22558. 2016-06-11 15:06:08 -04:00
Terry Jan Reedy fa089b9b0b Issue #22558: Add remaining doc links to source code for Python-coded modules.
Reformat header above separator line (added if missing) to a common format.
Patch by Yoni Lavi.
2016-06-11 15:02:54 -04:00
Martin Panter e514093a2f Issue #27125: Merge typo fixes from 3.5 2016-05-30 05:24:49 +00:00
Martin Panter a90a4a9651 Issue #27125: Remove duplicated words from documentation and comments 2016-05-30 04:04:50 +00:00
Martin Panter e501a93c18 Issue #27125: Merge typo fixes from 3.5
Also merge changes from Issue #27117; no actual code changes to 3.6.
2016-05-29 09:05:06 +00:00
Martin Panter 8d56c026a5 Issue #27125: Fix various errors like “will [be] inherited” 2016-05-29 04:13:35 +00:00
Berker Peksag 955bc38b16 Issue #26322: Document typing.Set, patch by Joseph Moran 2016-04-29 14:41:41 +03:00
Berker Peksag 5d6fd8c936 Issue #26322: Document typing.Set, patch by Joseph Moran 2016-04-29 14:41:16 +03:00
Victor Stinner 21de67f900 Merge 3.5 2016-04-11 16:23:37 +02:00
Victor Stinner a9901e86ba typing doc: add versionadded 3.5 2016-04-11 16:23:22 +02:00
Brett Cannon 9e080e0e74 Issue #25609: Introduce contextlib.AbstractContextManager and
typing.ContextManager.
2016-04-08 12:15:27 -07:00
Guido van Rossum 16ca06b8cb Add collections.Reversible. Patch by Ivan Levkivskyi. Fixes issue #25987. 2016-04-04 10:59:29 -07:00
Guido van Rossum 3fb5612e08 Hopefully clarify the difference between Optional[t] and an optional argument. 2016-02-10 09:46:56 -08:00
Zachary Ware 3df11b2bd6 Fix typo.
Reported by Jon Tetlak on docs@
2016-02-02 17:04:41 -06:00
Zachary Ware c730931fa1 Issue #25603: Add missing parenthesis. 2015-11-11 22:59:44 -06:00
Berker Peksag 573e2cd383 Fix typos and improve markup in typing.rst. 2015-09-10 21:55:50 +03:00
Guido van Rossum 2a19d956ab Restore doc updates to typing.rst by Ivan Levkivskyi and Daniel Andrade Groppe. 2015-09-10 10:52:11 -07:00
Zachary Ware ce50802679 Issue #24272: Remove usage of default reST role from typing docs 2015-08-29 22:39:47 -05:00
Guido van Rossum 9db397c5c1 Fix trailing ws. 2015-08-05 12:26:07 +02:00
Guido van Rossum eb184e0106 Issue #24272: Initial docs for typing.py (PEP 484).
By Daniel Andrade Groppe and Ivan Levkivskyi.
2015-08-03 22:35:46 +02:00
Guido van Rossum 46dbb7d103 Preliminary typing.py, anticipating provisional acceptance of PEP 484.
There area bunch of TODOs here, but the biggest (not mentioned in the
file) is that I'm going to take out __instancecheck__ and
__subclasscheck__.  However my personal schedule is such that I
probably won't have time for these before Larry tags beta 1.  But I
will try -- this commit is mostly to make sure that typing.py doesn't
completely miss the train.

PS. I'm tracking issues at https://github.com/ambv/typehinting/issues.
2015-05-22 10:14:11 -07:00
Guido van Rossum e93b06a0a3 Hopefully clarify the difference between Optional[t] and an optional argument. 2016-02-10 09:48:58 -08:00