backport _typeshed.Self

This commit is contained in:
Thomas Grainger 2021-07-20 14:11:05 +01:00
parent 16db3dcf86
commit a35252eefd
No known key found for this signature in database
GPG key ID: E452A1247BAC1A88
3 changed files with 12 additions and 4 deletions

View file

@ -2,7 +2,7 @@
# https://github.com/python/typeshed/blob/64c85cdd449ccaff90b546676220c9ecfa6e697f/LICENSE
import sys
from _typeshed import Self
from ._typeshed import Self
from types import TracebackType
from typing import (
IO,

5
contextlib2/_typeshed.py Normal file
View file

@ -0,0 +1,5 @@
from typing import TypeVar
# Use for "self" annotations:
# def __enter__(self: Self) -> Self: ...
Self = TypeVar("Self")

View file

@ -1,12 +1,15 @@
--- ../contextlib.pyi 2021-07-16 08:26:16.409945194 +0100
+++ contextlib2/__init__.pyi 2021-07-16 08:32:00.363150171 +0100
@@ -1,3 +1,6 @@
+++ contextlib2/__init__.pyi 2021-07-20 14:10:49.571136279 +0100
@@ -1,5 +1,8 @@
+# Type hints copied from the typeshed project under the Apache License 2.0
+# https://github.com/python/typeshed/blob/64c85cdd449ccaff90b546676220c9ecfa6e697f/LICENSE
+
import sys
from _typeshed import Self
-from _typeshed import Self
+from ._typeshed import Self
from types import TracebackType
from typing import (
IO,
@@ -17,8 +20,14 @@
)
from typing_extensions import ParamSpec, Protocol