Skip to content

Commit 6588680

Browse files
authored
Fix mypy deps and support Python 3.8-3.12 (#862)
1 parent 9bfbcbc commit 6588680

File tree

5 files changed

+232
-238
lines changed

5 files changed

+232
-238
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu-latest, windows-latest, macos-latest]
27-
python-version: ["3.7", "3.11"]
27+
python-version: ["3.8", "3.12"]
2828
include:
2929
- os: windows-latest
3030
python-version: "3.9"
@@ -33,7 +33,7 @@ jobs:
3333
- os: ubuntu-latest
3434
python-version: "3.10"
3535
- os: macos-latest
36-
python-version: "3.8"
36+
python-version: "3.11"
3737

3838
steps:
3939
- uses: actions/checkout@v4
@@ -62,7 +62,7 @@ jobs:
6262
dependency_type: minimum
6363
- name: Run the unit tests
6464
run: |
65-
hatch run test:nowarn || hatch run test:nowarn --lf
65+
hatch run test:nowarn || hatch -v run test:nowarn --lf
6666
6767
test_lint:
6868
name: Test Lint

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ classifiers = [
1818
"Programming Language :: Python :: 3",
1919
]
2020
urls = {Homepage = "https://github.com/ipython/traitlets"}
21-
requires-python = ">=3.7"
21+
requires-python = ">=3.8"
2222
dynamic = ["version"]
23-
dependencies = ["typing_extensions>=4.0.1"]
2423

2524
[project.optional-dependencies]
26-
test = ["pytest>=7.0,<7.5", "pytest-mock", "pre-commit", "argcomplete>=2.0", "pytest-mypy-testing", "mypy @ git+https://github.com/python/mypy.git@cb1d1a0baba37f35268cb605b7345726f257f960#egg=mypy"]
25+
test = ["pytest>=7.0,<7.5", "pytest-mock", "pre-commit", "argcomplete>=3.0.3", "pytest-mypy-testing", "mypy>=1.5.1"]
2726
docs = [
2827
"myst-parser",
2928
"pydata-sphinx-theme",
@@ -56,7 +55,6 @@ nowarn = "test -W default {args}"
5655

5756
[tool.hatch.envs.typing]
5857
features = ["test"]
59-
dependencies = ["mypy @ git+https://github.com/python/mypy.git@cb1d1a0baba37f35268cb605b7345726f257f960#egg=mypy"]
6058
[tool.hatch.envs.typing.scripts]
6159
test = "mypy --install-types --non-interactive {args:.}"
6260

@@ -76,6 +74,7 @@ fmt = [
7674
]
7775

7876
[tool.mypy]
77+
python_version = "3.8"
7978
check_untyped_defs = true
8079
disallow_any_generics = true
8180
disallow_incomplete_defs = true

traitlets/config/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def _show_config_json_changed(self, change):
444444
def _show_config_changed(self, change):
445445
if change.new:
446446
self._save_start = self.start
447-
self.start = self.start_show_config # type:ignore[assignment]
447+
self.start = self.start_show_config # type:ignore[method-assign]
448448

449449
def __init__(self, **kwargs):
450450
SingletonConfigurable.__init__(self, **kwargs)

traitlets/tests/test_typing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from __future__ import annotations
2+
13
import typing
2-
from typing import Optional
34

45
import pytest
56

@@ -63,7 +64,7 @@ class T(HasTraits):
6364
def mypy_int_typing():
6465
class T(HasTraits):
6566
i: Int[int, int] = Int(42).tag(sync=True)
66-
oi: Int[Optional[int], Optional[int]] = Int(42, allow_none=True).tag(sync=True)
67+
oi: Int[int | None, int | None] = Int(42, allow_none=True).tag(sync=True)
6768

6869
t = T()
6970
reveal_type(Int(True)) # R: traitlets.traitlets.Int[builtins.int, builtins.int]

0 commit comments

Comments
 (0)