Skip to content

Commit

Permalink
Update typing for traitlets 5.13 (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Nov 3, 2023
1 parent 586cbb3 commit 79fa122
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions jupyter_client/ioloop/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions jupyter_client/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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."
)

Expand Down
25 changes: 7 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -289,4 +278,4 @@ fail-under=90
exclude = ["docs", "test"]

[tool.repo-review]
ignore = ["PY007", "PP308", "GH102", "PC140"]
ignore = ["PY007", "PP308", "GH102"]

0 comments on commit 79fa122

Please sign in to comment.