From 165a49f7d1ed096168d33edb1efb11c220cce668 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 3 Nov 2023 07:32:46 -0500 Subject: [PATCH] update typing for traitlets 5.13 --- .github/workflows/main.yml | 2 +- .pre-commit-config.yaml | 10 ++++++++++ jupyter_client/ioloop/manager.py | 4 ++-- jupyter_client/kernelspec.py | 4 ++-- pyproject.toml | 25 +++++++------------------ 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f47e12a..9fe57ae8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -100,7 +100,7 @@ jobs: - name: Run Linters run: | hatch run typing:test - hatch run lint:style + hatch run lint:build pipx run interrogate -v . pipx run doc8 --max-line-length=200 --ignore-path=docs/source/other/full-config.rst diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 54233bbb..ddc94f86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,6 +36,16 @@ repos: - id: prettier types_or: [yaml, html, json] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v1.6.1" + hooks: + - id: mypy + files: jupyter_client + stages: [manual] + args: ["--install-types", "--non-interactive"] + additional_dependencies: + ["traitlets>=5.13", "ipykernel>=6.26", "jupyter_core>=5.3.2"] + - repo: https://github.com/adamchainz/blacken-docs rev: "1.16.0" hooks: diff --git a/jupyter_client/ioloop/manager.py b/jupyter_client/ioloop/manager.py index 3c44e612..5a6c8aec 100644 --- a/jupyter_client/ioloop/manager.py +++ b/jupyter_client/ioloop/manager.py @@ -56,7 +56,7 @@ def start_restarter(self) -> None: """Start the restarter.""" if self.autorestart and self.has_kernel: if self._restarter is None: - self._restarter = self.restarter_class( # type:ignore[operator] + self._restarter = self.restarter_class( kernel_manager=self, loop=self.loop, parent=self, log=self.log ) self._restarter.start() @@ -99,7 +99,7 @@ def start_restarter(self) -> None: """Start the restarter.""" if self.autorestart and self.has_kernel: if self._restarter is None: - self._restarter = self.restarter_class( # type:ignore[operator] + self._restarter = self.restarter_class( kernel_manager=self, loop=self.loop, parent=self, log=self.log ) self._restarter.start() diff --git a/jupyter_client/kernelspec.py b/jupyter_client/kernelspec.py index 63fd1ab6..41ed2bad 100644 --- a/jupyter_client/kernelspec.py +++ b/jupyter_client/kernelspec.py @@ -24,7 +24,7 @@ class KernelSpec(HasTraits): """A kernel spec model object.""" - argv = List() + argv: List[str] = List() name = Unicode() mimetype = Unicode() display_name = Unicode() @@ -160,7 +160,7 @@ def _user_kernel_dir_default(self) -> str: By default, all installed kernels are allowed. """, ) - kernel_dirs = List( + kernel_dirs: List[str] = List( help="List of kernel directories to search. Later ones take priority over earlier." ) diff --git a/pyproject.toml b/pyproject.toml index 4b3ecaa1..24e543a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,27 +98,16 @@ test = "python -m pytest -vv --cov jupyter_client --cov-branch --cov-report term nowarn = "test -W default {args}" [tool.hatch.envs.typing] -features = ["test"] -dependencies = ["mypy~=1.6", "traitlets>=5.11.2", "ipykernel>=6.26", "jupyter_core>=5.3.2"] +dependencies = ["pre-commit"] +detached = true [tool.hatch.envs.typing.scripts] -test = "mypy --install-types --non-interactive {args}" +test = "pre-commit run --all-files --hook-stage manual mypy" [tool.hatch.envs.lint] -dependencies = [ - "mdformat>0.7", - "ruff==0.1.3", -] +dependencies = ["pre-commit"] +detached = true [tool.hatch.envs.lint.scripts] -style = [ - "ruff {args:.}", - "ruff format {args:.}", - "mdformat --check {args:docs *.md}" -] -fmt = [ - "ruff --fix {args:.}", - "ruff format {args:.}", - "mdformat {args:docs *.md}" -] +build = ["pre-commit run --all-files ruff"] [tool.pytest.ini_options] minversion = "6.0" @@ -289,4 +278,4 @@ fail-under=90 exclude = ["docs", "test"] [tool.repo-review] -ignore = ["PY007", "PP308", "GH102", "PC140"] +ignore = ["PY007", "PP308", "GH102"]