Commit Graph

50 Commits

Author SHA1 Message Date
Ivan Levkivskyi d911e40e78
bpo-32226: PEP 560: improve typing module (#4906)
This PR re-designs the internal typing API using the new PEP 560 features.
However, there are only few minor changes in the public API.
2018-01-20 11:23:59 +00:00
Ivan Levkivskyi 29bc193210 [bpo-28556] Minor fixes for typing module (#4710) 2017-12-04 21:43:58 -05:00
Łukasz Langa f350a268a7 bpo-28556: typing.get_type_hints: better globalns for classes and modules (#3582)
This makes the default behavior (without specifying `globalns` manually) more
predictable for users, finds the right globalns automatically.

Implementation for classes assumes has a `__module__` attribute and that module
is present in `sys.modules`.  It does this recursively for all bases in the
MRO.  For modules, the implementation just uses their `__dict__` directly.

This is backwards compatible, will just raise fewer exceptions in naive user
code.

Originally implemented and reviewed at https://github.com/python/typing/pull/470.
2017-09-14 14:33:00 -04:00
Ivan Levkivskyi 65bc62052f bpo-28556: Minor updates to typing module (#3550)
* Copy changes to typing from upstream repo
* Add NEWS entry
2017-09-13 19:25:15 -04:00
Ivan Levkivskyi 29fda8db16 bpo-28556: Updates to typing module (#2076)
This PR contains two updates to typing module:

- Support ContextManager on all versions (original PR by Jelle Zijlstra).
- Add generic AsyncContextManager.
2017-06-10 12:57:56 -07:00
Ivan Levkivskyi f06e0218ef bpo-28556: Routine updates to typing (#1366)
- Add NoReturn type
- Use WrapperDescriptorType (original PR by Jim Fasarakis-Hilliard)
- Minor bug-fixes
2017-05-02 10:14:07 -07:00
Ivan Levkivskyi 365cb5bb90 bpo-28556: Fix regression that sneaked into recent typing updates (GH-270) 2017-02-24 09:28:26 -08:00
Ivan Levkivskyi abb3b8ad94 Update to typing: treat subscripted generics as proxies (#265) 2017-02-23 19:03:28 -08:00
Ivan Levkivskyi b692dc8475 bpo-28556: Various updates to typing (#28)
various updates from upstream python/typing repo:

- Added typing.Counter and typing.ChainMap generics
- More flexible typing.NamedTuple
- Improved generic ABC caching
- More tests
- Bugfixes
- Other updates

* Add Misc/NEWS entry

* Add issue number
2017-02-13 13:50:14 -08:00
Guido van Rossum 95919c096c Issue #28556: Allow defining methods in NamedTuple class syntax (#362) 2017-01-22 17:47:20 -08:00
Guido van Rossum d7adfe129c Issue #28556: various style fixes for typing.py 2017-01-22 17:43:53 -08:00
Guido van Rossum e9ed560fce Issue #29198: add AsyncGenerator (Jelle Zijlstra) 2017-01-18 13:10:31 -08:00
Guido van Rossum 3c268be885 Issue #28556: allow default values in class form of NamedTuple -- Jelle Zijlstra 2017-01-18 08:03:50 -08:00
Guido van Rossum 83ec302e52 Issue #28556: merge 5 more typing changes from upstream (#340, #344, #348, #349, #350) 2017-01-17 20:43:28 -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
Guido van Rossum 61f0a0261f Issue #28790: Fix error when using Generic and __slots__ (Ivan L) 2016-11-29 09:46:21 -08:00
Guido van Rossum b24569a19d Issue #28556: upstream improvements to docstrings and error messages by Ivan Levkivskyi (#331) 2016-11-20 18:01:29 -08:00
Guido van Rossum ca4b252fba Issue #28556: two more small upstream changes by Ivan Levkivskyi (#329, #330) 2016-11-19 10:32:41 -08:00
Guido van Rossum 2f84144235 Issue #28556: Allow keyword syntax for NamedTuple (Ivan Levkivskyi) (upstream #321) 2016-11-15 09:48:06 -08:00
Guido van Rossum dad179075a Issue #28649: fix second issue with _ForwardRef (#328) 2016-11-10 08:29:18 -08:00
Guido van Rossum c7b92950c9 Issue #28649: fix first issue with _ForwardRef (#327) 2016-11-10 08:24:06 -08:00
Guido van Rossum 9b10756019 Issue #28649: typing-clear-caches.patch 2016-11-09 13:23:04 -08:00
Guido van Rossum 991d14fee1 Issue #28556: More typing.py updates from upstream. 2016-11-09 13:12:51 -08:00
Guido van Rossum 62fe1bb983 Issue #28556: updates to typing.py (add Coroutine, prohibit Generic[T]()) 2016-10-29 16:05:26 -07:00
Guido van Rossum b7dedc89f1 Issue #28556: updates to typing.py (fix copy, deepcopy, pickle) 2016-10-29 12:44:29 -07:00
Guido van Rossum 5fc25a873c Issue #28556: updates to typing.py 2016-10-29 08:54:56 -07:00
Guido van Rossum 3b557991d4 Two minor typing.py fixes (upstream #305) 2016-10-21 17:30:29 -07:00
Guido van Rossum 9f91e858ce Fix indent 2016-10-21 14:30:50 -07:00
Guido van Rossum 7ef22d6b96 Sync typing.py from upstream 2016-10-21 14:27:58 -07:00
Guido van Rossum 5e2a0ef2ee Issue #28339: Remove ByteString.register(memoryview(...)) from typing.py. 2016-10-09 10:02:49 -07:00
Guido van Rossum e259267e52 Merge further typing.py changes from upstream. 2016-10-08 20:27:22 -07:00
Guido van Rossum b47c9d29d7 More updates from upstream typing.py 2016-10-03 08:40:50 -07:00
Guido van Rossum 4cefe74aef Update typing.py and test_typing.py from upstream (https://github.com/python/typing) 2016-09-27 15:20:12 -07:00
Guido van Rossum 0a6976da10 Issue #28079: Update typing and test typing from python/typing repo.
Ivan Levkivskyi (3.5 version)
2016-09-11 15:34:56 -07:00
Guido van Rossum efa798d1ba A new version of typing.py from https://github.com/python/typing. 2016-08-23 11:01:50 -07:00
Guido van Rossum 91185fe028 Sync typing.py with upstream.
(Upstream is https://github.com/python/typing)

- Add TYPE_CHECKING (false at runtime, true in type checkers) (upstream #230).
- Avoid error on Union[xml.etree.cElementTree.Element, str] (upstream #229).
- Repr of Tuple[()] should be 'Tuple[()]' (upstream #231).
- Add NewType() (upstream #189).
2016-06-08 11:19:11 -07:00
Guido van Rossum b22c708989 Comment/docstring tweaks for typing.py. 2016-05-26 09:56:19 -07:00
Guido van Rossum eb9aca3c07 Added Type[C] implementation to typing.py. 2016-05-24 16:38:22 -07:00
Guido van Rossum 1cea70f08c Fix #27014 -- infinite recursion using typing.py. 2016-05-18 08:35:00 -07:00
Guido van Rossum 5abcbb3ee5 typing.py: Consider ellipsis in TupleMeta.__eq__. By Kalle Tuure. github.com/python/typing/pull/201. 2016-04-18 07:37:41 -07:00
Brett Cannon f3ad042bfb Issue #25609: Backport typing.ContextManager.
This has no semantic impact as the class is guarded with a hasattr()
check; this is being done to keep typing.py in sync between Python 3.5
and 3.6 as requested by Guido.
2016-04-15 10:51:30 -07:00
Guido van Rossum 0e0563ca2c Add Text=str. Make ItemsView derive from AbstractSet, not Set (which is the concrete set). 2016-04-05 14:54:25 -07:00
Guido van Rossum bd5b9a0742 Many changes from the upstream repo (https://github.com/python/typing).
This syncs to rev 7b43ada77821d23e55e3a4b35f6055a59b9e1ad7 there.

Summary:

- Add typing.DefaultDict (as a generic variant of collections.defaultdict).

- Use collections.Reversible if it exists (only relevant for Python 3.6).

- Revamped generic class behavior to conform to updated PEP 484.

- Improve speed of Generic.__new__.

- Make sure __init__ is called for new Generic instances. Fix issue #26391.

- Refactor async support to be compatible with 3.2, 3.3, 3.4.

- Remove 'io' and 're' from __all__ (they still exist, just not
  included by "import *"). Fix issue #26234.

- Change @overload -- you can now use it outside stubs (you still
  cannot call the decorated function though).
2016-04-05 08:28:52 -07:00
Guido van Rossum f17c20076c Add Awaitable, AsyncIterable, AsyncIterator to typing.py. 2015-12-03 17:31:24 -08:00
Guido van Rossum 557d1eb0f3 Issue #25665: Make NamedTuple picklable. 2015-11-19 08:16:31 -08:00
Guido van Rossum bb7c57c6cd Issue #25472: In B[<type>], insert B in front of __bases__, to make the __dict__ descriptor work. 2015-11-18 21:12:58 -08:00
Guido van Rossum ca636eac88 Issue #25390: typing: Don't crash on Union[str, Pattern]. 2015-10-19 14:55:47 -07:00
Guido van Rossum 1b66910537 Fix issue #24635. 2015-09-04 12:15:54 -07:00
Guido van Rossum d70fe639c1 Issue #23973: Update typing.py from GitHub repo. 2015-08-05 12:11:06 +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