From 710bcd0b00d16b4482e53f89790cd98f29964291 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 29 May 2021 10:30:09 -0700 Subject: [PATCH 1/2] Use PEP 604 in types.pyi Let's see if it works. --- stdlib/types.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/types.pyi b/stdlib/types.pyi index e280150e3406..741d41d4ab79 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -34,9 +34,9 @@ class _Cell: cell_contents: Any class FunctionType: - __closure__: Optional[Tuple[_Cell, ...]] + __closure__: Tuple[_Cell, ...] | None __code__: CodeType - __defaults__: Optional[Tuple[Any, ...]] + __defaults__: Tuple[Any, ...] | None __dict__: Dict[str, Any] __globals__: Dict[str, Any] __name__: str @@ -47,12 +47,12 @@ class FunctionType: self, code: CodeType, globals: Dict[str, Any], - name: Optional[str] = ..., - argdefs: Optional[Tuple[object, ...]] = ..., - closure: Optional[Tuple[_Cell, ...]] = ..., + name: str | None = ..., + argdefs: Tuple[object, ...] | None = ..., + closure: Tuple[_Cell, ...] | None = ..., ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: Optional[object], type: Optional[type]) -> MethodType: ... + def __get__(self, obj: object | None, type: type | None) -> MethodType: ... LambdaType = FunctionType From 991e2089675c1ae7e9d05ccfd52eedce3a311131 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 29 May 2021 10:40:06 -0700 Subject: [PATCH 2/2] also update supported features in CONTRIBUTING --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 54433b23303b..fdcad75448bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,8 +140,6 @@ Accepted features that *cannot* yet be used in typeshed include: - [PEP 585](https://www.python.org/dev/peps/pep-0585/) (builtin generics): see [#4820](https://github.com/python/typeshed/issues/4820), mostly supported but bugs remain for a few specific cases -- [PEP 604](https://www.python.org/dev/peps/pep-0604/) (Union - pipe operator): see [#4819](https://github.com/python/typeshed/issues/4819) - [PEP 612](https://www.python.org/dev/peps/pep-0612/) (ParamSpec): see [#4827](https://github.com/python/typeshed/issues/4827) - [PEP 613](https://www.python.org/dev/peps/pep-0613/) (TypeAlias): @@ -154,6 +152,8 @@ Supported features include: - [PEP 589](https://www.python.org/dev/peps/pep-0589/) (TypedDict) - [PEP 647](https://www.python.org/dev/peps/pep-0647/) (TypeGuard): see [#5406](https://github.com/python/typeshed/issues/5406) +- [PEP 604](https://www.python.org/dev/peps/pep-0604/) (Union + pipe operator): see [#4819](https://github.com/python/typeshed/issues/4819) Features from the `typing` module that are not present in all supported Python 3 versions must be imported from `typing_extensions`