Skip to content
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

Fix mypy deps and support Python 3.8-3.12 #862

Merged
merged 8 commits into from
Sep 14, 2023
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.7", "3.11"]
python-version: ["3.8", "3.12"]
include:
- os: windows-latest
python-version: "3.9"
Expand All @@ -33,7 +33,7 @@ jobs:
- os: ubuntu-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.8"
python-version: "3.11"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
dependency_type: minimum
- name: Run the unit tests
run: |
hatch run test:nowarn || hatch run test:nowarn --lf
hatch run test:nowarn || hatch -v run test:nowarn --lf

test_lint:
name: Test Lint
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ classifiers = [
"Programming Language :: Python :: 3",
]
urls = {Homepage = "https://github.com/ipython/traitlets"}
requires-python = ">=3.7"
requires-python = ">=3.8"
dynamic = ["version"]
dependencies = ["typing_extensions>=4.0.1"]

[project.optional-dependencies]
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"]
test = ["pytest>=7.0,<7.5", "pytest-mock", "pre-commit", "argcomplete>=3.0.3", "pytest-mypy-testing", "mypy>=1.5.1"]
docs = [
"myst-parser",
"pydata-sphinx-theme",
Expand Down Expand Up @@ -56,7 +55,6 @@ nowarn = "test -W default {args}"

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

Expand All @@ -76,6 +74,7 @@ fmt = [
]

[tool.mypy]
python_version = "3.8"
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
Expand Down
2 changes: 1 addition & 1 deletion traitlets/config/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _show_config_json_changed(self, change):
def _show_config_changed(self, change):
if change.new:
self._save_start = self.start
self.start = self.start_show_config # type:ignore[assignment]
self.start = self.start_show_config # type:ignore[method-assign]

def __init__(self, **kwargs):
SingletonConfigurable.__init__(self, **kwargs)
Expand Down
5 changes: 3 additions & 2 deletions traitlets/tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import typing
from typing import Optional

import pytest

Expand Down Expand Up @@ -63,7 +64,7 @@ class T(HasTraits):
def mypy_int_typing():
class T(HasTraits):
i: Int[int, int] = Int(42).tag(sync=True)
oi: Int[Optional[int], Optional[int]] = Int(42, allow_none=True).tag(sync=True)
oi: Int[int | None, int | None] = Int(42, allow_none=True).tag(sync=True)

t = T()
reveal_type(Int(True)) # R: traitlets.traitlets.Int[builtins.int, builtins.int]
Expand Down
Loading