Skip to content

Commit ddd339c

Browse files
authored
build: relax runtime typing extensions dependency (#49)
* build: unpin typing_extensions * build: relax typing extensions deps
1 parent 096096a commit ddd339c

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_install_hook_types: [pre-commit, commit-msg]
77

88
repos:
99
- repo: https://github.com/compilerla/conventional-pre-commit
10-
rev: v1.3.0
10+
rev: v1.4.0
1111
hooks:
1212
- id: conventional-pre-commit
1313
stages: [commit-msg]
@@ -31,7 +31,7 @@ repos:
3131
- id: isort
3232

3333
- repo: https://github.com/asottile/pyupgrade
34-
rev: v2.34.0
34+
rev: v2.37.2
3535
hooks:
3636
- id: pyupgrade
3737
args: [--py38-plus, --keep-runtime-typing]
@@ -52,7 +52,7 @@ repos:
5252
- flake8-typing-imports
5353

5454
- repo: https://github.com/pre-commit/mirrors-mypy
55-
rev: v0.961
55+
rev: v0.971
5656
hooks:
5757
- id: mypy
5858
files: "^src/"

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
"Programming Language :: Python :: 3.10",
2121
]
2222
dynamic = ["version"]
23-
dependencies = ['psygnal', 'pydantic', 'in-n-out', 'typing_extensions>=4.0']
23+
dependencies = ['psygnal', 'pydantic', 'in-n-out', 'typing_extensions']
2424

2525
# extras
2626
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
@@ -54,6 +54,7 @@ docs = [
5454
"mkdocstrings-python==0.7.0",
5555
"mkdocstrings==0.19.0",
5656
"mkdocs-macros-plugin==0.7.0",
57+
"typing_extensions>=4.0",
5758
]
5859
[project.urls]
5960
homepage = "https://github.com/napari/app-model"
@@ -118,10 +119,7 @@ ignore = "D100,D213,D401,D413,D107"
118119
# https://docs.pytest.org/en/6.2.x/customize.html
119120
[tool.pytest.ini_options]
120121
minversion = "6.0"
121-
filterwarnings = [
122-
"error",
123-
"ignore:QPixmapCache.find:DeprecationWarning:",
124-
]
122+
filterwarnings = ["error", "ignore:QPixmapCache.find:DeprecationWarning:"]
125123

126124
# https://mypy.readthedocs.io/en/stable/config_file.html
127125
[tool.mypy]

src/app_model/expressions/_context_keys.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Dict,
99
Generic,
1010
List,
11+
Literal,
1112
MutableMapping,
1213
NamedTuple,
1314
Optional,
@@ -17,8 +18,6 @@
1718
overload,
1819
)
1920

20-
from typing_extensions import Literal
21-
2221
from ._expressions import Name
2322

2423
T = TypeVar("T")

src/app_model/registries/_commands_reg.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,39 @@
22

33
from concurrent.futures import Future, ThreadPoolExecutor
44
from functools import cached_property
5-
from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, TypeVar, Union, cast
5+
from typing import (
6+
TYPE_CHECKING,
7+
Any,
8+
Callable,
9+
Dict,
10+
Generic,
11+
Iterator,
12+
Optional,
13+
Tuple,
14+
TypeVar,
15+
Union,
16+
cast,
17+
)
618

719
from in_n_out import Store
820
from psygnal import Signal
9-
from typing_extensions import ParamSpec
1021

22+
# maintain runtime compatibility with older typing_extensions
1123
if TYPE_CHECKING:
12-
from typing import Dict, Iterator, Tuple
24+
from typing_extensions import ParamSpec
1325

14-
DisposeCallable = Callable[[], None]
26+
P = ParamSpec("P")
27+
else:
28+
try:
29+
from typing_extensions import ParamSpec
30+
31+
P = ParamSpec("P")
32+
except ImportError:
33+
P = TypeVar("P")
34+
35+
36+
DisposeCallable = Callable[[], None]
1537

16-
P = ParamSpec("P")
1738
R = TypeVar("R")
1839

1940

src/app_model/types/_action.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
from typing import Callable, Generic, List, Optional, TypeVar, Union
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING, Callable, Generic, List, Optional, TypeVar, Union
24

35
from pydantic import Field, validator
4-
from typing_extensions import ParamSpec
56

67
from ._command_rule import CommandRule
78
from ._keybinding_rule import KeyBindingRule
89
from ._menu_rule import MenuRule
910
from ._utils import _validate_python_name
1011

11-
P = ParamSpec("P")
12+
# maintain runtime compatibility with older typing_extensions
13+
if TYPE_CHECKING:
14+
from typing_extensions import ParamSpec
15+
16+
P = ParamSpec("P")
17+
else:
18+
try:
19+
from typing_extensions import ParamSpec
20+
21+
P = ParamSpec("P")
22+
except ImportError:
23+
P = TypeVar("P")
1224
R = TypeVar("R")
1325

1426

0 commit comments

Comments
 (0)