Skip to content

Commit 0282a89

Browse files
require Python 3.9 (#924)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b0eaa6a commit 0282a89

File tree

9 files changed

+21
-24
lines changed

9 files changed

+21
-24
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu-latest, windows-latest, macos-latest]
27-
python-version: ["3.8", "3.13"]
27+
python-version: ["3.9", "3.13"]
2828
include:
29-
- os: ubuntu-latest
30-
python-version: "3.9"
3129
- os: ubuntu-latest
3230
python-version: "3.10"
3331
- os: ubuntu-latest

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
"Programming Language :: Python",
2121
"Typing :: Typed",
2222
]
23-
requires-python = ">=3.8"
23+
requires-python = ">=3.9"
2424
dynamic = ["version"]
2525

2626
[project.urls]
@@ -86,7 +86,7 @@ build = [
8686

8787
[tool.mypy]
8888
files = "traitlets"
89-
python_version = "3.8"
89+
python_version = "3.9"
9090
strict = true
9191
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
9292
pretty = true

tests/test_typing.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,27 +407,27 @@ class T(HasTraits):
407407
otcp = TCPAddress(None, allow_none=True)
408408

409409
t = T()
410-
reveal_type(t.tcp) # R: Tuple[builtins.str, builtins.int]
410+
reveal_type(t.tcp) # R: tuple[builtins.str, builtins.int]
411411
reveal_type(
412-
T.tcp # R: traitlets.traitlets.TCPAddress[Tuple[builtins.str, builtins.int], Tuple[builtins.str, builtins.int]]
412+
T.tcp # R: traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int], tuple[builtins.str, builtins.int]]
413413
)
414414
reveal_type(
415-
T.tcp.tag( # R:traitlets.traitlets.TCPAddress[Tuple[builtins.str, builtins.int], Tuple[builtins.str, builtins.int]]
415+
T.tcp.tag( # R:traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int], tuple[builtins.str, builtins.int]]
416416
sync=True
417417
)
418418
)
419-
reveal_type(t.otcp) # R: Union[Tuple[builtins.str, builtins.int], None]
419+
reveal_type(t.otcp) # R: Union[tuple[builtins.str, builtins.int], None]
420420
reveal_type(
421-
T.otcp # R: traitlets.traitlets.TCPAddress[Union[Tuple[builtins.str, builtins.int], None], Union[Tuple[builtins.str, builtins.int], None]]
421+
T.otcp # R: traitlets.traitlets.TCPAddress[Union[tuple[builtins.str, builtins.int], None], Union[tuple[builtins.str, builtins.int], None]]
422422
)
423423
reveal_type(
424-
T.otcp.tag( # R: traitlets.traitlets.TCPAddress[Union[Tuple[builtins.str, builtins.int], None], Union[Tuple[builtins.str, builtins.int], None]]
424+
T.otcp.tag( # R: traitlets.traitlets.TCPAddress[Union[tuple[builtins.str, builtins.int], None], Union[tuple[builtins.str, builtins.int], None]]
425425
sync=True
426426
)
427427
)
428-
t.tcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "Tuple[str, int]") [assignment]
429-
t.otcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "Optional[Tuple[str, int]]") [assignment]
430-
t.tcp = None # E: Incompatible types in assignment (expression has type "None", variable has type "Tuple[str, int]") [assignment]
428+
t.tcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "tuple[str, int]") [assignment]
429+
t.otcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "Optional[tuple[str, int]]") [assignment]
430+
t.tcp = None # E: Incompatible types in assignment (expression has type "None", variable has type "tuple[str, int]") [assignment]
431431

432432

433433
@pytest.mark.mypy_testing

traitlets/_version.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from __future__ import annotations
55

66
import re
7-
from typing import List
87

98
# Version string must appear intact for hatch versioning
109
__version__ = "5.14.3"
@@ -13,7 +12,7 @@
1312
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
1413
match = re.match(pattern, __version__)
1514
assert match is not None
16-
parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
15+
parts: list[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
1716
if match["rest"]:
1817
parts.append(match["rest"])
1918
version_info = tuple(parts)

traitlets/tests/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

33
import sys
4+
from collections.abc import Sequence
45
from subprocess import PIPE, Popen
5-
from typing import Any, Sequence
6+
from typing import Any
67

78

89
def get_output_error_code(cmd: str | Sequence[str]) -> tuple[str, str, Any]:

traitlets/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import pathlib
5-
from typing import Sequence
5+
from collections.abc import Sequence
66

77

88
# vestigal things from IPython_genutils.

traitlets/utils/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import copy
55
from inspect import Parameter, Signature, signature
6-
from typing import Any, Type, TypeVar
6+
from typing import Any, TypeVar
77

88
from ..traitlets import HasTraits, Undefined
99

@@ -16,7 +16,7 @@ def _get_default(value: Any) -> Any:
1616
T = TypeVar("T", bound=HasTraits)
1717

1818

19-
def signature_has_traits(cls: Type[T]) -> Type[T]:
19+
def signature_has_traits(cls: type[T]) -> type[T]:
2020
"""Return a decorated class with a constructor signature that contain Trait names as kwargs."""
2121
traits = [
2222
(name, _get_default(value.default_value))

traitlets/utils/nested_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Distributed under the terms of the Modified BSD License.
33
from __future__ import annotations
44

5-
from typing import Any, Dict
5+
from typing import Any
66

77

8-
def nested_update(this: Dict[Any, Any], that: Dict[Any, Any]) -> Dict[Any, Any]:
8+
def nested_update(this: dict[Any, Any], that: dict[Any, Any]) -> dict[Any, Any]:
99
"""Merge two nested dictionaries.
1010
1111
Effectively a recursive ``dict.update``.

traitlets/utils/text.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import re
77
import textwrap
88
from textwrap import indent as _indent
9-
from typing import List
109

1110

1211
def indent(val: str) -> str:
@@ -32,7 +31,7 @@ def _dedent(text: str) -> str:
3231
return "\n".join([first, rest])
3332

3433

35-
def wrap_paragraphs(text: str, ncols: int = 80) -> List[str]:
34+
def wrap_paragraphs(text: str, ncols: int = 80) -> list[str]:
3635
"""Wrap multiple paragraphs to fit a specified width.
3736
3837
This is equivalent to textwrap.wrap, but with support for multiple

0 commit comments

Comments
 (0)