Skip to content

Commit b882a32

Browse files
authored
Clean up lint and typing (#1351)
1 parent a5c288c commit b882a32

File tree

35 files changed

+88
-78
lines changed

35 files changed

+88
-78
lines changed

.github/workflows/python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- name: Run Linters
8383
run: |
8484
hatch run typing:test
85-
hatch run lint:style
85+
hatch run lint:build
8686
pipx run interrogate -v .
8787
pipx run doc8 --max-line-length=200 --ignore-path=docs/source/other/full-config.rst
8888
npm install -g eslint

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ repos:
5757
- id: rst-directive-colons
5858
- id: rst-inline-touching-normal
5959

60+
- repo: https://github.com/pre-commit/mirrors-mypy
61+
rev: "v1.6.1"
62+
hooks:
63+
- id: mypy
64+
files: jupyter_server
65+
stages: [manual]
66+
additional_dependencies:
67+
["traitlets>=5.13", "jupyter_core>=5.5", "jupyter_client>=8.5"]
68+
6069
- repo: https://github.com/astral-sh/ruff-pre-commit
6170
rev: v0.1.3
6271
hooks:

CONTRIBUTING.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Some of the hooks only run on CI by default, but you can invoke them by
7070
running with the ``--hook-stage manual`` argument.
7171

7272
There are three hatch scripts that can be run locally as well:
73-
``hatch run lint:style`` will check styling. ``hatch run lint:fmt``
74-
will attempt to auto-format files. ``hatch run typing:test`` will
73+
``hatch run lint:build`` will enforce styling. ``hatch run typing:test`` will
7574
run the type checker.
7675

7776
Troubleshooting the Installation

examples/identity/system_password/jupyter_server_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pwd
33
from getpass import getuser
44

5-
from pamela import PAMError, authenticate # type:ignore[import-not-found]
5+
from pamela import PAMError, authenticate
66

77
from jupyter_server.auth.identity import IdentityProvider, User
88

jupyter_server/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
JUPYTER_SERVER_EVENTS_URI = "https://events.jupyter.org/jupyter_server"
1313
DEFAULT_EVENTS_SCHEMA_PATH = pathlib.Path(__file__).parent / "event_schemas"
1414

15-
del os
15+
from ._version import __version__, version_info
16+
from .base.call_context import CallContext
1617

17-
from ._version import __version__, version_info # noqa
18-
from .base.call_context import CallContext # noqa
19-
20-
21-
def _cleanup():
22-
pass
18+
__all__ = [
19+
"DEFAULT_STATIC_FILES_PATH",
20+
"DEFAULT_TEMPLATE_PATH_LIST",
21+
"DEFAULT_JUPYTER_SERVER_PORT",
22+
"JUPYTER_SERVER_EVENTS_URI",
23+
"DEFAULT_EVENTS_SCHEMA_PATH",
24+
"__version__",
25+
"version_info",
26+
"CallContext",
27+
]

jupyter_server/auth/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .authorizer import * # noqa
2-
from .decorator import authorized # noqa
3-
from .identity import * # noqa
4-
from .security import passwd # noqa
1+
from .authorizer import * # noqa: F403
2+
from .decorator import authorized # noqa: F401
3+
from .identity import * # noqa: F403
4+
from .security import passwd # noqa: F401

jupyter_server/auth/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from jupyter_core.paths import jupyter_config_dir
88
from traitlets.log import get_logger
99

10-
from jupyter_server.auth import passwd
10+
from jupyter_server.auth import passwd # type:ignore[attr-defined]
1111
from jupyter_server.config_manager import BaseJSONConfigManager
1212

1313

jupyter_server/auth/security.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from contextlib import contextmanager
1212

1313
from jupyter_core.paths import jupyter_config_dir
14-
from traitlets.config import Config, ConfigFileNotFound, JSONFileConfigLoader
14+
from traitlets.config import Config
15+
from traitlets.config.loader import ConfigFileNotFound, JSONFileConfigLoader
1516

1617
# Length of the salt in nr of hex chars, which implies salt_len * 4
1718
# bits of randomness.

jupyter_server/base/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from jupyter_server import CallContext
3131
from jupyter_server._sysinfo import get_sys_info
3232
from jupyter_server._tz import utcnow
33-
from jupyter_server.auth import authorized
33+
from jupyter_server.auth.decorator import authorized
3434
from jupyter_server.i18n import combine_translations
3535
from jupyter_server.services.security import csp_report_uri
3636
from jupyter_server.utils import (

jupyter_server/files/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from jupyter_core.utils import ensure_async
1111
from tornado import web
1212

13-
from jupyter_server.auth import authorized
13+
from jupyter_server.auth.decorator import authorized
1414
from jupyter_server.base.handlers import JupyterHandler
1515

1616
AUTH_RESOURCE = "contents"

0 commit comments

Comments
 (0)