File tree Expand file tree Collapse file tree 5 files changed +35
-9
lines changed
Expand file tree Collapse file tree 5 files changed +35
-9
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,19 @@ Internal Modules
2525 :undoc-members:
2626 :show-inheritance:
2727
28+ :mod: `~PIL._typing ` Module
29+ --------------------------
30+
31+ .. module :: PIL._typing
32+
33+ Provides a convenient way to import type hints that are not available
34+ on some supported Python versions.
35+
36+ .. py :data :: TypeGuard
37+ :value: typing.TypeGuard
38+
39+ See :py:obj: `typing.TypeGuard `.
40+
2841:mod: `~PIL._util ` Module
2942------------------------
3043
Original file line number Diff line number Diff line change @@ -37,9 +37,6 @@ classifiers = [
3737dynamic = [
3838 " version" ,
3939]
40- dependencies = [
41- ' typing-extensions; python_version < "3.10"' ,
42- ]
4340[project .optional-dependencies ]
4441docs = [
4542 " furo" ,
@@ -68,6 +65,9 @@ tests = [
6865 " pytest-cov" ,
6966 " pytest-timeout" ,
7067]
68+ typing = [
69+ ' typing-extensions; python_version < "3.10"' ,
70+ ]
7171xmp = [
7272 " defusedxml" ,
7373]
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ if sys .version_info >= (3 , 10 ):
4+ from typing import TypeGuard
5+ else :
6+ try :
7+ from typing_extensions import TypeGuard
8+ except ImportError :
9+ from typing import Any , Type
10+
11+ class TypeGuard : # type: ignore[no-redef]
12+ def __class_getitem__ (cls , item : Any ) -> Type [bool ]:
13+ return bool
14+
15+
16+ __all__ = ["TypeGuard" ]
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import os
4- import sys
54from pathlib import Path
65from typing import Any , NoReturn
7-
8- if sys .version_info >= (3 , 10 ):
9- from typing import TypeGuard
10- else :
11- from typing_extensions import TypeGuard
6+ from ._typing import TypeGuard
127
138
149def is_path (f : Any ) -> TypeGuard [bytes | str | Path ]:
Original file line number Diff line number Diff line change 3737 numpy
3838commands =
3939 mypy src {posargs}
40+ extras =
41+ typing
You can’t perform that action at this time.
0 commit comments