Skip to content

require Python 3.9 #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.13"]
python-version: ["3.9", "3.13"]
include:
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
"Programming Language :: Python",
"Typing :: Typed",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dynamic = ["version"]

[project.urls]
Expand Down Expand Up @@ -86,7 +86,7 @@ build = [

[tool.mypy]
files = "traitlets"
python_version = "3.8"
python_version = "3.9"
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
pretty = true
Expand Down
18 changes: 9 additions & 9 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,27 +407,27 @@ class T(HasTraits):
otcp = TCPAddress(None, allow_none=True)

t = T()
reveal_type(t.tcp) # R: Tuple[builtins.str, builtins.int]
reveal_type(t.tcp) # R: tuple[builtins.str, builtins.int]
reveal_type(
T.tcp # R: traitlets.traitlets.TCPAddress[Tuple[builtins.str, builtins.int], Tuple[builtins.str, builtins.int]]
T.tcp # R: traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int], tuple[builtins.str, builtins.int]]
)
reveal_type(
T.tcp.tag( # R:traitlets.traitlets.TCPAddress[Tuple[builtins.str, builtins.int], Tuple[builtins.str, builtins.int]]
T.tcp.tag( # R:traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int], tuple[builtins.str, builtins.int]]
sync=True
)
)
reveal_type(t.otcp) # R: Union[Tuple[builtins.str, builtins.int], None]
reveal_type(t.otcp) # R: Union[tuple[builtins.str, builtins.int], None]
reveal_type(
T.otcp # R: traitlets.traitlets.TCPAddress[Union[Tuple[builtins.str, builtins.int], None], Union[Tuple[builtins.str, builtins.int], None]]
T.otcp # R: traitlets.traitlets.TCPAddress[Union[tuple[builtins.str, builtins.int], None], Union[tuple[builtins.str, builtins.int], None]]
)
reveal_type(
T.otcp.tag( # R: traitlets.traitlets.TCPAddress[Union[Tuple[builtins.str, builtins.int], None], Union[Tuple[builtins.str, builtins.int], None]]
T.otcp.tag( # R: traitlets.traitlets.TCPAddress[Union[tuple[builtins.str, builtins.int], None], Union[tuple[builtins.str, builtins.int], None]]
sync=True
)
)
t.tcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "Tuple[str, int]") [assignment]
t.otcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "Optional[Tuple[str, int]]") [assignment]
t.tcp = None # E: Incompatible types in assignment (expression has type "None", variable has type "Tuple[str, int]") [assignment]
t.tcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "tuple[str, int]") [assignment]
t.otcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "Optional[tuple[str, int]]") [assignment]
t.tcp = None # E: Incompatible types in assignment (expression has type "None", variable has type "tuple[str, int]") [assignment]


@pytest.mark.mypy_testing
Expand Down
3 changes: 1 addition & 2 deletions traitlets/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from __future__ import annotations

import re
from typing import List

# Version string must appear intact for hatch versioning
__version__ = "5.14.3"
Expand All @@ -13,7 +12,7 @@
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
match = re.match(pattern, __version__)
assert match is not None
parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
parts: list[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
if match["rest"]:
parts.append(match["rest"])
version_info = tuple(parts)
3 changes: 2 additions & 1 deletion traitlets/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import sys
from collections.abc import Sequence
from subprocess import PIPE, Popen
from typing import Any, Sequence
from typing import Any


def get_output_error_code(cmd: str | Sequence[str]) -> tuple[str, str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion traitlets/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
import pathlib
from typing import Sequence
from collections.abc import Sequence


# vestigal things from IPython_genutils.
Expand Down
4 changes: 2 additions & 2 deletions traitlets/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import copy
from inspect import Parameter, Signature, signature
from typing import Any, Type, TypeVar
from typing import Any, TypeVar

from ..traitlets import HasTraits, Undefined

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


def signature_has_traits(cls: Type[T]) -> Type[T]:
def signature_has_traits(cls: type[T]) -> type[T]:
"""Return a decorated class with a constructor signature that contain Trait names as kwargs."""
traits = [
(name, _get_default(value.default_value))
Expand Down
4 changes: 2 additions & 2 deletions traitlets/utils/nested_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

from typing import Any, Dict
from typing import Any


def nested_update(this: Dict[Any, Any], that: Dict[Any, Any]) -> Dict[Any, Any]:
def nested_update(this: dict[Any, Any], that: dict[Any, Any]) -> dict[Any, Any]:
"""Merge two nested dictionaries.

Effectively a recursive ``dict.update``.
Expand Down
3 changes: 1 addition & 2 deletions traitlets/utils/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re
import textwrap
from textwrap import indent as _indent
from typing import List


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


def wrap_paragraphs(text: str, ncols: int = 80) -> List[str]:
def wrap_paragraphs(text: str, ncols: int = 80) -> list[str]:
"""Wrap multiple paragraphs to fit a specified width.

This is equivalent to textwrap.wrap, but with support for multiple
Expand Down