Skip to content

Commit

Permalink
Merge branch 'main' of github.com:jupyter-server/jupyter_server
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Nov 7, 2023
2 parents e88cd7c + f282873 commit b2b7cba
Show file tree
Hide file tree
Showing 39 changed files with 132 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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
npm install -g eslint
Expand Down
13 changes: 11 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: 0.27.1
hooks:
- id: check-github-workflows

Expand Down Expand Up @@ -57,8 +57,17 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.6.1"
hooks:
- id: mypy
files: jupyter_server
stages: [manual]
additional_dependencies:
["traitlets>=5.13", "jupyter_core>=5.5", "jupyter_client>=8.5"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
rev: v0.1.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
25 changes: 23 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.

<!-- <START NEW CHANGELOG ENTRY> -->

## 2.10.0

([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v2.9.1...e71e95884483c7ce2d9fd5ee83059a0269741aa1))

### Enhancements made

- Update kernel env to reflect changes in session [#1354](https://github.com/jupyter-server/jupyter_server/pull/1354) ([@blink1073](https://github.com/blink1073))

### Maintenance and upkeep improvements

- Clean up config and address warnings [#1353](https://github.com/jupyter-server/jupyter_server/pull/1353) ([@blink1073](https://github.com/blink1073))
- Clean up lint and typing [#1351](https://github.com/jupyter-server/jupyter_server/pull/1351) ([@blink1073](https://github.com/blink1073))
- Update typing for traitlets 5.13 [#1350](https://github.com/jupyter-server/jupyter_server/pull/1350) ([@blink1073](https://github.com/blink1073))
- Update typings and fix tests [#1344](https://github.com/jupyter-server/jupyter_server/pull/1344) ([@blink1073](https://github.com/blink1073))

### Contributors to this release

([GitHub contributors page for this release](https://github.com/jupyter-server/jupyter_server/graphs/contributors?from=2023-10-25&to=2023-11-06&type=c))

[@blink1073](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Ablink1073+updated%3A2023-10-25..2023-11-06&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 2.9.1

([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v2.9.0...bb293ec5cac5b277259f27e458da60fa8a926f46))
Expand All @@ -18,8 +41,6 @@ All notable changes to this project will be documented in this file.

[@blink1073](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Ablink1073+updated%3A2023-10-25..2023-10-25&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 2.9.0

([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v2.8.0...3438ddb16575155e98fc4f49700fff420088c8b0))
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ Some of the hooks only run on CI by default, but you can invoke them by
running with the ``--hook-stage manual`` argument.

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

Troubleshooting the Installation
Expand Down
2 changes: 1 addition & 1 deletion examples/identity/system_password/jupyter_server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pwd
from getpass import getuser

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

from jupyter_server.auth.identity import IdentityProvider, User

Expand Down
19 changes: 12 additions & 7 deletions jupyter_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
JUPYTER_SERVER_EVENTS_URI = "https://events.jupyter.org/jupyter_server"
DEFAULT_EVENTS_SCHEMA_PATH = pathlib.Path(__file__).parent / "event_schemas"

del os
from ._version import __version__, version_info
from .base.call_context import CallContext

from ._version import __version__, version_info # noqa
from .base.call_context import CallContext # noqa


def _cleanup():
pass
__all__ = [
"DEFAULT_STATIC_FILES_PATH",
"DEFAULT_TEMPLATE_PATH_LIST",
"DEFAULT_JUPYTER_SERVER_PORT",
"JUPYTER_SERVER_EVENTS_URI",
"DEFAULT_EVENTS_SCHEMA_PATH",
"__version__",
"version_info",
"CallContext",
]
20 changes: 7 additions & 13 deletions jupyter_server/_tz.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

from datetime import datetime, timedelta, tzinfo
from typing import Callable
from datetime import datetime, timedelta, timezone, tzinfo

# constant for zero offset
ZERO = timedelta(0)
Expand All @@ -26,21 +25,16 @@ def dst(self, d: datetime | None) -> timedelta:
return ZERO


UTC = tzUTC() # type:ignore[abstract]

def utcnow() -> datetime:
"""Return timezone-aware UTC timestamp"""
return datetime.now(timezone.utc)

def utc_aware(unaware: Callable[..., datetime]) -> Callable[..., datetime]:
"""decorator for adding UTC tzinfo to datetime's utcfoo methods"""

def utc_method(*args, **kwargs):
dt = unaware(*args, **kwargs)
return dt.replace(tzinfo=UTC)
def utcfromtimestamp(timestamp):
return datetime.fromtimestamp(timestamp, timezone.utc)

return utc_method


utcfromtimestamp = utc_aware(datetime.utcfromtimestamp)
utcnow = utc_aware(datetime.utcnow)
UTC = tzUTC() # type:ignore[abstract]


def isoformat(dt: datetime) -> str:
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import List

# Version string must appear intact for automatic versioning
__version__ = "2.10.0.dev0"
__version__ = "2.11.0.dev0"

# Build up version_info tuple for backwards compatibility
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
Expand Down
8 changes: 4 additions & 4 deletions jupyter_server/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .authorizer import * # noqa
from .decorator import authorized # noqa
from .identity import * # noqa
from .security import passwd # noqa
from .authorizer import * # noqa: F403
from .decorator import authorized # noqa: F401
from .identity import * # noqa: F403
from .security import passwd # noqa: F401
2 changes: 1 addition & 1 deletion jupyter_server/auth/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from jupyter_core.paths import jupyter_config_dir
from traitlets.log import get_logger

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


Expand Down
3 changes: 2 additions & 1 deletion jupyter_server/auth/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from contextlib import contextmanager

from jupyter_core.paths import jupyter_config_dir
from traitlets.config import Config, ConfigFileNotFound, JSONFileConfigLoader
from traitlets.config import Config
from traitlets.config.loader import ConfigFileNotFound, JSONFileConfigLoader

# Length of the salt in nr of hex chars, which implies salt_len * 4
# bits of randomness.
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from jupyter_server import CallContext
from jupyter_server._sysinfo import get_sys_info
from jupyter_server._tz import utcnow
from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized
from jupyter_server.i18n import combine_translations
from jupyter_server.services.security import csp_report_uri
from jupyter_server.utils import (
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/files/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from jupyter_core.utils import ensure_async
from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized
from jupyter_server.base.handlers import JupyterHandler

AUTH_RESOURCE = "contents"
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/gateway/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from ..services.kernels.connection.base import BaseKernelWebsocketConnection
from ..utils import url_path_join
from .managers import GatewayClient
from .gateway_client import GatewayClient


class GatewayWebSocketConnection(BaseKernelWebsocketConnection):
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/gateway/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from ..base.handlers import APIHandler, JupyterHandler
from ..utils import url_path_join
from .managers import GatewayClient
from .gateway_client import GatewayClient

warnings.warn(
"The jupyter_server.gateway.handlers module is deprecated and will not be supported in Jupyter Server 3.0",
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/gateway/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from time import monotonic
from typing import Any, Dict, Optional

import websocket # type:ignore[import-untyped]
import websocket
from jupyter_client.asynchronous.client import AsyncKernelClient
from jupyter_client.clientabc import KernelClientABC
from jupyter_client.kernelspec import KernelSpecManager
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/kernelspecs/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from jupyter_core.utils import ensure_async
from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized

from ..base.handlers import JupyterHandler
from ..services.kernelspecs.handlers import kernel_name_regex
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/nbconvert/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tornado import web
from tornado.log import app_log

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized

from ..base.handlers import FilesRedirectHandler, JupyterHandler, path_regex

Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/prometheus/log_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Log functions for prometheus"""
from .metrics import HTTP_REQUEST_DURATION_SECONDS
from .metrics import HTTP_REQUEST_DURATION_SECONDS # type:ignore[unused-ignore]


def prometheus_log_method(handler):
Expand Down
9 changes: 8 additions & 1 deletion jupyter_server/prometheus/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Jupyter Notebook also defines these metrics. Re-defining them results in a ValueError.
# Try to de-duplicate by using the ones in Notebook if available.
# See https://github.com/jupyter/jupyter_server/issues/209
from notebook.prometheus.metrics import ( # type:ignore[import-not-found]
from notebook.prometheus.metrics import (
HTTP_REQUEST_DURATION_SECONDS,
KERNEL_CURRENTLY_RUNNING_TOTAL,
TERMINAL_CURRENTLY_RUNNING_TOTAL,
Expand All @@ -34,3 +34,10 @@
"counter for how many kernels are running labeled by type",
["type"],
)


__all__ = [
"HTTP_REQUEST_DURATION_SECONDS",
"TERMINAL_CURRENTLY_RUNNING_TOTAL",
"KERNEL_CURRENTLY_RUNNING_TOTAL",
]
6 changes: 3 additions & 3 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
from jupyter_server.extension.manager import ExtensionManager
from jupyter_server.extension.serverextension import ServerExtensionApp
from jupyter_server.gateway.connections import GatewayWebSocketConnection
from jupyter_server.gateway.gateway_client import GatewayClient
from jupyter_server.gateway.managers import (
GatewayClient,
GatewayKernelSpecManager,
GatewayMappingKernelManager,
GatewaySessionManager,
Expand Down Expand Up @@ -323,7 +323,7 @@ def init_settings(
localedir=os.path.join(base_dir, "jupyter_server/i18n"),
fallback=True,
)
env.install_gettext_translations(nbui, newstyle=False) # type:ignore[attr-defined]
env.install_gettext_translations(nbui, newstyle=False)

if sys_info["commit_source"] == "repository":
# don't cache (rely on 304) when working from master
Expand Down Expand Up @@ -1913,7 +1913,7 @@ def init_configurables(self) -> None:
"connection_dir": self.runtime_dir,
"kernel_spec_manager": self.kernel_spec_manager,
}
if jupyter_client.version_info > (8, 3, 0):
if jupyter_client.version_info > (8, 3, 0): # type:ignore[attr-defined]
if self.allow_external_kernels:
external_connection_dir = self.external_connection_dir
if external_connection_dir is None:
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tornado import web

from jupyter_server._tz import isoformat, utcfromtimestamp
from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized

from ...base.handlers import APIHandler, JupyterHandler

Expand Down
4 changes: 3 additions & 1 deletion jupyter_server/services/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .manager import ConfigManager # noqa
from .manager import ConfigManager

__all__ = ["ConfigManager"]
2 changes: 1 addition & 1 deletion jupyter_server/services/config/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized

from ...base.handlers import APIHandler

Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/contents/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from jupyter_core.utils import ensure_async
from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized
from jupyter_server.base.handlers import APIHandler, JupyterHandler, path_regex
from jupyter_server.utils import url_escape, url_path_join

Expand Down
3 changes: 1 addition & 2 deletions jupyter_server/services/contents/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import warnings
from fnmatch import fnmatch

from jupyter_client.utils import run_sync
from jupyter_core.utils import ensure_async
from jupyter_core.utils import ensure_async, run_sync
from jupyter_events import EventLogger
from nbformat import ValidationError, sign
from nbformat import validate as validate_nb
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/events/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import jupyter_events.logger
from tornado import web, websocket

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized
from jupyter_server.base.handlers import JupyterHandler

from ...base.handlers import APIHandler
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/kernels/connection/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from concurrent.futures import Future
from textwrap import dedent

from jupyter_client import protocol_version as client_protocol_version
from jupyter_client import protocol_version as client_protocol_version # type:ignore[attr-defined]
from tornado import gen, web
from tornado.ioloop import IOLoop
from tornado.websocket import WebSocketClosedError
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from jupyter_core.utils import ensure_async
from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized
from jupyter_server.utils import url_escape, url_path_join

from ...base.handlers import APIHandler
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/kernelspecs/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from jupyter_core.utils import ensure_async
from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized

from ...base.handlers import APIHandler
from ...utils import url_path_join, url_unescape
Expand Down
2 changes: 1 addition & 1 deletion jupyter_server/services/nbconvert/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from anyio.to_thread import run_sync
from tornado import web

from jupyter_server.auth import authorized
from jupyter_server.auth.decorator import authorized

from ...base.handlers import APIHandler

Expand Down
Loading

0 comments on commit b2b7cba

Please sign in to comment.