Commit Graph

62 Commits

Author SHA1 Message Date
Miss Islington (bot) 98b089e2a1
bpo-33652: Remove __getstate__ and __setstate__ methods in typing. (GH-7144)
(cherry picked from commit 97b523db7c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-28 04:21:44 -07:00
Miss Islington (bot) d49862582e
bpo-33652: Improve pickle support in the typing module. (GH-7123)
Pickles of type variables and subscripted generics are now future-proof
and compatible with older Python versions.
(cherry picked from commit 09f3221fbb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-26 11:38:00 -07:00
Miss Islington (bot) 0f9b68a728
Reverse the meaning of is_argument when used for type check (GH-7039)
(cherry picked from commit 0e61dffdba)

Co-authored-by: Nina Zakharenko <nzakharenko@gmail.com>
2018-05-22 20:51:15 -07:00
Miss Islington (bot) 09ca5906b7 bpo-28556: Don't simplify unions at runtime (GH-6841) (GH-6979)
(cherry picked from commit f65e31fee3)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2018-05-18 16:27:14 -07:00
Miss Islington (bot) 9c17cd3214 Fix ClassVar as string fails when getting type hints (GH-6824) (#6912)
(cherry picked from commit 2d2d3b170b)

Co-authored-by: Nina Zakharenko <nzakharenko@gmail.com>
2018-05-16 18:04:39 -04:00
Miss Islington (bot) c5444b3556
Fix a bug in Generic.__new__ (GH-6758)
(cherry picked from commit b551e9f0ff)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2018-05-10 20:30:47 -07:00
Miss Islington (bot) 3c28a6387b
bpo-28556: Minor fixes for typing module (GH-6732)
This also fixes https://bugs.python.org/issue33420
(cherry picked from commit 43d12a6bd8)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2018-05-08 18:44:09 -07:00
Miss Islington (bot) 32955299b4
Spelling fixes to docs, docstrings, and comments (GH-6374)
(cherry picked from commit 61f82e0e33)

Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
2018-04-20 14:00:41 -07:00
Miss Islington (bot) 04eac02088
bpo-32873: Remove a name hack for generic aliases in typing module (GH-6376)
This removes a hack and replaces it with a proper
mapping {'list': 'List', 'dict': 'Dict', ...}.
(cherry picked from commit 2a363d2930)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2018-04-04 17:46:40 -07:00
Miss Islington (bot) bd85c97382
Call super in Generic.__init_subclass__ (GH-6356)
(cherry picked from commit ee566fe526)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2018-04-04 09:51:34 -07:00
Miss Islington (bot) d0e04c8244
bpo-32873: Treat type variables and special typing forms as immutable by copy and pickle (GH-6216)
This also fixes python/typingGH-512
This also fixes python/typingGH-511

As was discussed in both issues, some typing forms deserve to be treated
as immutable by copy and pickle modules, so that:
* copy(X) is X
* deepcopy(X) is X
* loads(dumps(X)) is X  GH- pickled by reference

This PR adds such behaviour to:
* Type variables
* Special forms like Union, Any, ClassVar
* Unsubscripted generic aliases to containers like List, Mapping, Iterable

This not only resolves inconsistencies mentioned in the issues, but also
improves backwards compatibility with previous versions of Python
(including 3.6).

Note that this requires some dances with __module__ for type variables
(similar to NamedTuple) because the class TypeVar itself is define in typing,
while type variables should get module where they were defined.

https://bugs.python.org/issue32873
(cherry picked from commit 834940375a)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2018-03-26 15:29:06 -07:00
Ivan Levkivskyi ac5602746e
bpo-33061: Add missing 'NoReturn' to __all__ in typing.py (GH-6127) (#6162) 2018-03-23 21:44:54 +00:00
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