Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Oct 1, 2023
1 parent 4ce5713 commit 09b6be4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions jupyter_server/_tz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

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

Expand Down
8 changes: 5 additions & 3 deletions jupyter_server/services/events/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
.. versionadded:: 2.0
"""
from __future__ import annotations

import json
from datetime import datetime
from typing import Any, Dict, Optional, cast
from typing import Any, cast

from jupyter_events import EventLogger
from tornado import web, websocket
Expand Down Expand Up @@ -63,15 +65,15 @@ def on_close(self):
self.event_logger.remove_listener(listener=self.event_listener)


def validate_model(data: Dict[str, Any]) -> None:
def validate_model(data: dict[str, Any]) -> None:
"""Validates for required fields in the JSON request body"""
required_keys = {"schema_id", "version", "data"}
for key in required_keys:
if key not in data:
raise web.HTTPError(400, f"Missing `{key}` in the JSON request body.")


def get_timestamp(data: Dict[str, Any]) -> Optional[datetime]:
def get_timestamp(data: dict[str, Any]) -> datetime | None:
"""Parses timestamp from the JSON request body"""
try:
if "timestamp" in data:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ pydist_resource_paths = ["jupyter_server/static/style/bootstrap.min.css", "jupyt
post-version-spec = "dev"

[tool.mypy]
python_version = "3.8"
check_untyped_defs = true
disallow_incomplete_defs = true
no_implicit_optional = true
Expand Down

0 comments on commit 09b6be4

Please sign in to comment.