diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e9be5161..d2ba8ed8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,11 +15,6 @@ repos: - id: check-builtin-literals - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 23.10.0 - hooks: - - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.1 hooks: diff --git a/README.md b/README.md index f0689ef0..4f443313 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![Build Status](https://github.com/jupyter-server/jupyverse/workflows/CI/badge.svg)](https://github.com/jupyter-server/jupyverse/actions) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) # jupyverse diff --git a/jupyverse_api/jupyverse_api/__init__.py b/jupyverse_api/jupyverse_api/__init__.py index 0e3ada56..8e1ad16a 100644 --- a/jupyverse_api/jupyverse_api/__init__.py +++ b/jupyverse_api/jupyverse_api/__init__.py @@ -4,7 +4,6 @@ from .app import App - __version__ = "0.3.0" diff --git a/jupyverse_api/jupyverse_api/app/__init__.py b/jupyverse_api/jupyverse_api/app/__init__.py index d28d1576..ad1144ce 100644 --- a/jupyverse_api/jupyverse_api/app/__init__.py +++ b/jupyverse_api/jupyverse_api/app/__init__.py @@ -1,15 +1,14 @@ from __future__ import annotations import logging -from datetime import datetime, timezone from collections import defaultdict +from datetime import datetime, timezone from typing import Dict, List from fastapi import FastAPI, Request from ..exceptions import RedirectException, _redirect_exception_handler - logger = logging.getLogger("app") diff --git a/jupyverse_api/jupyverse_api/auth/models.py b/jupyverse_api/jupyverse_api/auth/models.py index c6337013..b8cc741a 100644 --- a/jupyverse_api/jupyverse_api/auth/models.py +++ b/jupyverse_api/jupyverse_api/auth/models.py @@ -1,4 +1,5 @@ from typing import Optional + from pydantic import BaseModel diff --git a/jupyverse_api/jupyverse_api/cli.py b/jupyverse_api/jupyverse_api/cli.py index 3a10f5cc..913bd5c4 100644 --- a/jupyverse_api/jupyverse_api/cli.py +++ b/jupyverse_api/jupyverse_api/cli.py @@ -1,6 +1,6 @@ -import pkg_resources from typing import List, Tuple +import pkg_resources import rich_click as click from asphalt.core.cli import run diff --git a/jupyverse_api/jupyverse_api/contents/__init__.py b/jupyverse_api/jupyverse_api/contents/__init__.py index 5f9b018f..4296e29b 100644 --- a/jupyverse_api/jupyverse_api/contents/__init__.py +++ b/jupyverse_api/jupyverse_api/contents/__init__.py @@ -4,11 +4,12 @@ from typing import Dict, List, Optional, Union from fastapi import APIRouter, Depends, Request, Response + from jupyverse_api import Router -from .models import Checkpoint, Content, SaveContent -from ..auth import Auth, User from ..app import App +from ..auth import Auth, User +from .models import Checkpoint, Content, SaveContent class FileIdManager(ABC): diff --git a/jupyverse_api/jupyverse_api/jupyterlab/__init__.py b/jupyverse_api/jupyverse_api/jupyterlab/__init__.py index 1d6b8694..36f18b56 100644 --- a/jupyverse_api/jupyverse_api/jupyterlab/__init__.py +++ b/jupyverse_api/jupyverse_api/jupyterlab/__init__.py @@ -2,10 +2,11 @@ from fastapi import APIRouter, Depends, Request from fastapi.responses import HTMLResponse + from jupyverse_api import Config, Router -from ..auth import Auth, User from ..app import App +from ..auth import Auth, User class JupyterLab(Router, ABC): diff --git a/jupyverse_api/jupyverse_api/kernels/__init__.py b/jupyverse_api/jupyverse_api/kernels/__init__.py index ee79f73e..597fe20e 100644 --- a/jupyverse_api/jupyverse_api/kernels/__init__.py +++ b/jupyverse_api/jupyverse_api/kernels/__init__.py @@ -3,9 +3,10 @@ from typing import List, Optional from fastapi import APIRouter, Depends, Request -from jupyverse_api import Router, Config from pydantic import Field +from jupyverse_api import Config, Router + from ..app import App from ..auth import Auth, User from .models import Session diff --git a/jupyverse_api/jupyverse_api/lab/__init__.py b/jupyverse_api/jupyverse_api/lab/__init__.py index 245e2000..dac9ebab 100644 --- a/jupyverse_api/jupyverse_api/lab/__init__.py +++ b/jupyverse_api/jupyverse_api/lab/__init__.py @@ -5,11 +5,12 @@ from fastapi import APIRouter, Depends, Request, Response from fastapi.staticfiles import StaticFiles + from jupyverse_api import Router from jupyverse_api.jupyterlab import JupyterLabConfig -from ..auth import Auth, User from ..app import App +from ..auth import Auth, User class Lab(Router, ABC): diff --git a/jupyverse_api/jupyverse_api/login/__init__.py b/jupyverse_api/jupyverse_api/login/__init__.py index aadde1bc..66a6e323 100644 --- a/jupyverse_api/jupyverse_api/login/__init__.py +++ b/jupyverse_api/jupyverse_api/login/__init__.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod from fastapi import APIRouter + from jupyverse_api import Router from ..app import App diff --git a/jupyverse_api/jupyverse_api/nbconvert/__init__.py b/jupyverse_api/jupyverse_api/nbconvert/__init__.py index 83e267b8..ba536ae4 100644 --- a/jupyverse_api/jupyverse_api/nbconvert/__init__.py +++ b/jupyverse_api/jupyverse_api/nbconvert/__init__.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod from fastapi import APIRouter, Depends + from jupyverse_api import Router from ..app import App diff --git a/jupyverse_api/jupyverse_api/resource_usage/__init__.py b/jupyverse_api/jupyverse_api/resource_usage/__init__.py index 53d68423..1baf3eb1 100644 --- a/jupyverse_api/jupyverse_api/resource_usage/__init__.py +++ b/jupyverse_api/jupyverse_api/resource_usage/__init__.py @@ -1,10 +1,11 @@ from abc import ABC, abstractmethod from fastapi import APIRouter, Depends -from jupyverse_api import Router, Config -from ..auth import Auth, User +from jupyverse_api import Config, Router + from ..app import App +from ..auth import Auth, User class ResourceUsage(Router, ABC): diff --git a/jupyverse_api/jupyverse_api/retrolab/__init__.py b/jupyverse_api/jupyverse_api/retrolab/__init__.py index ecc5a0fc..113f91ed 100644 --- a/jupyverse_api/jupyverse_api/retrolab/__init__.py +++ b/jupyverse_api/jupyverse_api/retrolab/__init__.py @@ -2,6 +2,7 @@ from fastapi import APIRouter, Depends from fastapi.responses import HTMLResponse + from jupyverse_api import Router from ..app import App diff --git a/jupyverse_api/jupyverse_api/terminals/__init__.py b/jupyverse_api/jupyverse_api/terminals/__init__.py index ace3805c..ae2f5b96 100644 --- a/jupyverse_api/jupyverse_api/terminals/__init__.py +++ b/jupyverse_api/jupyverse_api/terminals/__init__.py @@ -2,11 +2,12 @@ from typing import List from fastapi import APIRouter, Depends + from jupyverse_api import Router -from .models import Terminal from ..app import App from ..auth import Auth, User +from .models import Terminal class Terminals(Router, ABC): diff --git a/jupyverse_api/jupyverse_api/yjs/__init__.py b/jupyverse_api/jupyverse_api/yjs/__init__.py index 088d2f07..7a8dfa5b 100644 --- a/jupyverse_api/jupyverse_api/yjs/__init__.py +++ b/jupyverse_api/jupyverse_api/yjs/__init__.py @@ -2,10 +2,11 @@ from typing import Any from fastapi import APIRouter, Depends, Request, Response + from jupyverse_api import Router -from ..auth import Auth, User from ..app import App +from ..auth import Auth, User class Yjs(Router, ABC): diff --git a/plugins/auth/fps_auth/backends.py b/plugins/auth/fps_auth/backends.py index 0a3882ca..4fba571e 100644 --- a/plugins/auth/fps_auth/backends.py +++ b/plugins/auth/fps_auth/backends.py @@ -20,15 +20,15 @@ from fastapi_users.authentication.transport.base import Transport from fastapi_users.db import SQLAlchemyUserDatabase from httpx_oauth.clients.github import GitHubOAuth2 +from starlette.requests import Request + from jupyverse_api.exceptions import RedirectException from jupyverse_api.frontend import FrontendConfig -from starlette.requests import Request from .config import _AuthConfig from .db import User from .models import UserCreate, UserRead - logger = logging.getLogger("auth") diff --git a/plugins/auth/fps_auth/db.py b/plugins/auth/fps_auth/db.py index 100f682f..96455494 100644 --- a/plugins/auth/fps_auth/db.py +++ b/plugins/auth/fps_auth/db.py @@ -5,8 +5,8 @@ from typing import Any, AsyncGenerator, List from fastapi import Depends -from fastapi_users.db import SQLAlchemyBaseOAuthAccountTableUUID from fastapi_users.db import ( + SQLAlchemyBaseOAuthAccountTableUUID, SQLAlchemyBaseUserTableUUID, SQLAlchemyUserDatabase, ) @@ -16,7 +16,6 @@ from .config import _AuthConfig - logger = logging.getLogger("auth") diff --git a/plugins/auth/fps_auth/main.py b/plugins/auth/fps_auth/main.py index 3829d8a5..8670a084 100644 --- a/plugins/auth/fps_auth/main.py +++ b/plugins/auth/fps_auth/main.py @@ -2,15 +2,15 @@ from asphalt.core import Component, Context from fastapi_users.exceptions import UserAlreadyExists + +from jupyverse_api.app import App from jupyverse_api.auth import Auth, AuthConfig from jupyverse_api.frontend import FrontendConfig -from jupyverse_api.app import App from jupyverse_api.main import Host, QueryParams from .config import _AuthConfig from .routes import auth_factory - logger = logging.getLogger("auth") diff --git a/plugins/auth/fps_auth/models.py b/plugins/auth/fps_auth/models.py index 92295dcf..caa44d0d 100644 --- a/plugins/auth/fps_auth/models.py +++ b/plugins/auth/fps_auth/models.py @@ -2,6 +2,7 @@ from typing import Dict, List from fastapi_users import schemas + from jupyverse_api.auth import User diff --git a/plugins/auth/fps_auth/routes.py b/plugins/auth/fps_auth/routes.py index 53134523..dd24863f 100644 --- a/plugins/auth/fps_auth/routes.py +++ b/plugins/auth/fps_auth/routes.py @@ -5,19 +5,18 @@ from typing import Any, Callable, Dict, List, Optional, Tuple from fastapi import APIRouter, Depends +from sqlalchemy import select # type: ignore + from jupyverse_api import Router from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.frontend import FrontendConfig -from sqlalchemy import select # type: ignore from .backends import get_backend from .config import _AuthConfig from .db import get_db - from .models import UserCreate, UserRead, UserUpdate - logger = logging.getLogger("auth") diff --git a/plugins/auth_fief/fps_auth_fief/backend.py b/plugins/auth_fief/fps_auth_fief/backend.py index 09bcccb4..f943ef5b 100644 --- a/plugins/auth_fief/fps_auth_fief/backend.py +++ b/plugins/auth_fief/fps_auth_fief/backend.py @@ -5,6 +5,7 @@ from fastapi.security import APIKeyCookie from fief_client import FiefAccessTokenInfo, FiefAsync, FiefUserInfo from fief_client.integrations.fastapi import FiefAuth + from jupyverse_api.auth import User from .config import _AuthFiefConfig diff --git a/plugins/auth_fief/fps_auth_fief/config.py b/plugins/auth_fief/fps_auth_fief/config.py index 4e4877f8..89f37a90 100644 --- a/plugins/auth_fief/fps_auth_fief/config.py +++ b/plugins/auth_fief/fps_auth_fief/config.py @@ -1,6 +1,7 @@ -from jupyverse_api.auth import AuthConfig from pydantic import Field +from jupyverse_api.auth import AuthConfig + class _AuthFiefConfig(AuthConfig): base_url: str = Field(description="Base URL of Fief tenant") diff --git a/plugins/auth_fief/fps_auth_fief/main.py b/plugins/auth_fief/fps_auth_fief/main.py index bcd55cb3..ddc8224f 100644 --- a/plugins/auth_fief/fps_auth_fief/main.py +++ b/plugins/auth_fief/fps_auth_fief/main.py @@ -1,6 +1,7 @@ from asphalt.core import Component, Context -from jupyverse_api.auth import Auth, AuthConfig + from jupyverse_api.app import App +from jupyverse_api.auth import Auth, AuthConfig from .config import _AuthFiefConfig from .routes import auth_factory diff --git a/plugins/auth_fief/fps_auth_fief/routes.py b/plugins/auth_fief/fps_auth_fief/routes.py index 0986f5c4..fa65f6b9 100644 --- a/plugins/auth_fief/fps_auth_fief/routes.py +++ b/plugins/auth_fief/fps_auth_fief/routes.py @@ -5,6 +5,7 @@ from fastapi import APIRouter, Depends, Query, Request, Response from fastapi.responses import RedirectResponse from fief_client import FiefAccessTokenInfo + from jupyverse_api import Router from jupyverse_api.app import App from jupyverse_api.auth import Auth, User diff --git a/plugins/auth_jupyterhub/fps_auth_jupyterhub/config.py b/plugins/auth_jupyterhub/fps_auth_jupyterhub/config.py index 35ed108f..6b2c24b2 100644 --- a/plugins/auth_jupyterhub/fps_auth_jupyterhub/config.py +++ b/plugins/auth_jupyterhub/fps_auth_jupyterhub/config.py @@ -1,6 +1,7 @@ -from jupyverse_api.auth import AuthConfig from pydantic import Field +from jupyverse_api.auth import AuthConfig + class AuthJupyterHubConfig(AuthConfig): db_url: str = Field( diff --git a/plugins/auth_jupyterhub/fps_auth_jupyterhub/main.py b/plugins/auth_jupyterhub/fps_auth_jupyterhub/main.py index 7b64025c..8b9a8b71 100644 --- a/plugins/auth_jupyterhub/fps_auth_jupyterhub/main.py +++ b/plugins/auth_jupyterhub/fps_auth_jupyterhub/main.py @@ -1,9 +1,10 @@ import httpx from asphalt.core import Component, ContainerComponent, Context, context_teardown -from jupyverse_api.auth import Auth, AuthConfig -from jupyverse_api.app import App from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession +from jupyverse_api.app import App +from jupyverse_api.auth import Auth, AuthConfig + from .config import AuthJupyterHubConfig from .db import Base from .routes import auth_factory diff --git a/plugins/auth_jupyterhub/fps_auth_jupyterhub/models.py b/plugins/auth_jupyterhub/fps_auth_jupyterhub/models.py index aa3f8bad..6c4c2856 100644 --- a/plugins/auth_jupyterhub/fps_auth_jupyterhub/models.py +++ b/plugins/auth_jupyterhub/fps_auth_jupyterhub/models.py @@ -1,8 +1,9 @@ from typing import Dict, List -from jupyverse_api.auth import User from pydantic import ConfigDict +from jupyverse_api.auth import User + class JupyterHubUser(User): model_config = ConfigDict(from_attributes=True) diff --git a/plugins/auth_jupyterhub/fps_auth_jupyterhub/routes.py b/plugins/auth_jupyterhub/fps_auth_jupyterhub/routes.py index 9e835384..e0cb72e6 100644 --- a/plugins/auth_jupyterhub/fps_auth_jupyterhub/routes.py +++ b/plugins/auth_jupyterhub/fps_auth_jupyterhub/routes.py @@ -5,18 +5,19 @@ import os from datetime import datetime from typing import Any, Callable, Dict, List, Optional, Tuple, Union -from typing_extensions import Annotated import httpx from fastapi import APIRouter, Cookie, Depends, HTTPException, Request, WebSocket, status from fastapi.responses import RedirectResponse from jupyterhub.services.auth import HubOAuth from jupyterhub.utils import isoformat +from sqlalchemy.ext.asyncio import AsyncSession +from sqlalchemy.future import select +from typing_extensions import Annotated + from jupyverse_api import Router from jupyverse_api.app import App from jupyverse_api.auth import Auth, User -from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.future import select from .db import UserDB from .models import JupyterHubUser diff --git a/plugins/contents/fps_contents/fileid.py b/plugins/contents/fps_contents/fileid.py index 1b251361..f489c59d 100644 --- a/plugins/contents/fps_contents/fileid.py +++ b/plugins/contents/fps_contents/fileid.py @@ -5,9 +5,10 @@ import aiosqlite from anyio import Path -from jupyverse_api import Singleton from watchfiles import Change, awatch +from jupyverse_api import Singleton + logger = logging.getLogger("contents") @@ -49,7 +50,7 @@ async def get_id(self, path: str) -> Optional[str]: async with self.lock: async with aiosqlite.connect(self.db_path) as db: async with db.execute("SELECT id FROM fileids WHERE path = ?", (path,)) as cursor: - async for idx, in cursor: + async for (idx,) in cursor: return idx return None @@ -58,7 +59,7 @@ async def get_path(self, idx: str) -> Optional[str]: async with self.lock: async with aiosqlite.connect(self.db_path) as db: async with db.execute("SELECT path FROM fileids WHERE id = ?", (idx,)) as cursor: - async for path, in cursor: + async for (path,) in cursor: return path return None @@ -174,7 +175,7 @@ def unwatch(self, path: str, watcher: Watcher): async def get_mtime(path, db) -> Optional[float]: if db: async with db.execute("SELECT mtime FROM fileids WHERE path = ?", (path,)) as cursor: - async for mtime, in cursor: + async for (mtime,) in cursor: return mtime # deleted file is not in database, shouldn't happen return None diff --git a/plugins/contents/fps_contents/main.py b/plugins/contents/fps_contents/main.py index 36dc5cfe..81f6fd18 100644 --- a/plugins/contents/fps_contents/main.py +++ b/plugins/contents/fps_contents/main.py @@ -1,4 +1,5 @@ from asphalt.core import Component, Context + from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.contents import Contents diff --git a/plugins/contents/fps_contents/routes.py b/plugins/contents/fps_contents/routes.py index c216353c..7f759b9e 100644 --- a/plugins/contents/fps_contents/routes.py +++ b/plugins/contents/fps_contents/routes.py @@ -9,6 +9,8 @@ from anyio import open_file from fastapi import HTTPException, Response +from starlette.requests import Request + from jupyverse_api.auth import User from jupyverse_api.contents import Contents from jupyverse_api.contents.models import ( @@ -18,7 +20,6 @@ RenameContent, SaveContent, ) -from starlette.requests import Request from .fileid import FileIdManager diff --git a/plugins/frontend/fps_frontend/main.py b/plugins/frontend/fps_frontend/main.py index 1ff637a5..b34b488b 100644 --- a/plugins/frontend/fps_frontend/main.py +++ b/plugins/frontend/fps_frontend/main.py @@ -1,4 +1,5 @@ from asphalt.core import Component, Context + from jupyverse_api.frontend import FrontendConfig diff --git a/plugins/jupyterlab/fps_jupyterlab/main.py b/plugins/jupyterlab/fps_jupyterlab/main.py index ec2fd86f..2cd31dd9 100644 --- a/plugins/jupyterlab/fps_jupyterlab/main.py +++ b/plugins/jupyterlab/fps_jupyterlab/main.py @@ -1,4 +1,5 @@ from asphalt.core import Component, Context + from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.frontend import FrontendConfig diff --git a/plugins/jupyterlab/fps_jupyterlab/routes.py b/plugins/jupyterlab/fps_jupyterlab/routes.py index 0cc49ea8..50e8b802 100644 --- a/plugins/jupyterlab/fps_jupyterlab/routes.py +++ b/plugins/jupyterlab/fps_jupyterlab/routes.py @@ -6,12 +6,13 @@ from fastapi import Response from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles +from starlette.requests import Request + from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.frontend import FrontendConfig from jupyverse_api.jupyterlab import JupyterLab, JupyterLabConfig from jupyverse_api.lab import Lab -from starlette.requests import Request from .index import INDEX_HTML diff --git a/plugins/kernels/fps_kernels/kernel_server/server.py b/plugins/kernels/fps_kernels/kernel_server/server.py index 1b11baa5..e10a2b84 100644 --- a/plugins/kernels/fps_kernels/kernel_server/server.py +++ b/plugins/kernels/fps_kernels/kernel_server/server.py @@ -9,9 +9,8 @@ from fastapi import WebSocket, WebSocketDisconnect from starlette.websockets import WebSocketState -from ..kernel_driver.connect import cfg_t, connect_channel +from ..kernel_driver.connect import cfg_t, connect_channel, read_connection_file from ..kernel_driver.connect import launch_kernel as _launch_kernel -from ..kernel_driver.connect import read_connection_file from ..kernel_driver.connect import ( write_connection_file as _write_connection_file, ) diff --git a/plugins/kernels/fps_kernels/main.py b/plugins/kernels/fps_kernels/main.py index 93cce3f7..3cb4abc2 100644 --- a/plugins/kernels/fps_kernels/main.py +++ b/plugins/kernels/fps_kernels/main.py @@ -1,4 +1,5 @@ from __future__ import annotations + import asyncio from collections.abc import AsyncGenerator from pathlib import Path @@ -6,11 +7,11 @@ from asphalt.core import Component, Context, context_teardown +from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.frontend import FrontendConfig from jupyverse_api.kernels import Kernels, KernelsConfig from jupyverse_api.yjs import Yjs -from jupyverse_api.app import App from .kernel_driver.paths import jupyter_runtime_dir from .routes import _Kernels diff --git a/plugins/kernels/fps_kernels/routes.py b/plugins/kernels/fps_kernels/routes.py index e87a7f9b..2f9a2a9a 100644 --- a/plugins/kernels/fps_kernels/routes.py +++ b/plugins/kernels/fps_kernels/routes.py @@ -9,12 +9,13 @@ from fastapi.responses import FileResponse from starlette.requests import Request from watchfiles import Change, awatch + +from jupyverse_api.app import App from jupyverse_api.auth import Auth, User +from jupyverse_api.frontend import FrontendConfig from jupyverse_api.kernels import Kernels, KernelsConfig from jupyverse_api.kernels.models import CreateSession, Execution, Kernel, Notebook, Session -from jupyverse_api.frontend import FrontendConfig from jupyverse_api.yjs import Yjs -from jupyverse_api.app import App from .kernel_driver.driver import KernelDriver from .kernel_driver.kernelspec import find_kernelspec, kernelspec_dirs @@ -24,7 +25,6 @@ kernels, ) - logger = logging.getLogger("kernels") diff --git a/plugins/lab/fps_lab/main.py b/plugins/lab/fps_lab/main.py index c03a42e6..50292912 100644 --- a/plugins/lab/fps_lab/main.py +++ b/plugins/lab/fps_lab/main.py @@ -1,4 +1,5 @@ from asphalt.core import Component, Context + from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.frontend import FrontendConfig diff --git a/plugins/lab/fps_lab/routes.py b/plugins/lab/fps_lab/routes.py index 00aefc8d..2fb98aa9 100644 --- a/plugins/lab/fps_lab/routes.py +++ b/plugins/lab/fps_lab/routes.py @@ -19,7 +19,6 @@ from jupyverse_api.jupyterlab import JupyterLabConfig from jupyverse_api.lab import Lab - logger = logging.getLogger("lab") diff --git a/plugins/login/fps_login/main.py b/plugins/login/fps_login/main.py index 23459edd..f513ca57 100644 --- a/plugins/login/fps_login/main.py +++ b/plugins/login/fps_login/main.py @@ -1,7 +1,8 @@ from asphalt.core import Component, Context + +from jupyverse_api.app import App from jupyverse_api.auth import AuthConfig from jupyverse_api.login import Login -from jupyverse_api.app import App from .routes import _Login diff --git a/plugins/login/fps_login/routes.py b/plugins/login/fps_login/routes.py index 5a3b1f4d..971eaaea 100644 --- a/plugins/login/fps_login/routes.py +++ b/plugins/login/fps_login/routes.py @@ -3,6 +3,7 @@ from fastapi.responses import FileResponse from fastapi.staticfiles import StaticFiles + from jupyverse_api.app import App from jupyverse_api.auth import AuthConfig from jupyverse_api.login import Login diff --git a/plugins/nbconvert/fps_nbconvert/main.py b/plugins/nbconvert/fps_nbconvert/main.py index b5c8d98f..c865adf8 100644 --- a/plugins/nbconvert/fps_nbconvert/main.py +++ b/plugins/nbconvert/fps_nbconvert/main.py @@ -1,6 +1,7 @@ from asphalt.core import Component, Context -from jupyverse_api.auth import Auth + from jupyverse_api.app import App +from jupyverse_api.auth import Auth from jupyverse_api.nbconvert import Nbconvert from .routes import _Nbconvert diff --git a/plugins/nbconvert/fps_nbconvert/routes.py b/plugins/nbconvert/fps_nbconvert/routes.py index e3fa33e8..2c67dfe3 100644 --- a/plugins/nbconvert/fps_nbconvert/routes.py +++ b/plugins/nbconvert/fps_nbconvert/routes.py @@ -3,6 +3,7 @@ import nbconvert from fastapi.responses import FileResponse + from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.nbconvert import Nbconvert diff --git a/plugins/noauth/fps_noauth/backends.py b/plugins/noauth/fps_noauth/backends.py index d042eb57..c814f195 100644 --- a/plugins/noauth/fps_noauth/backends.py +++ b/plugins/noauth/fps_noauth/backends.py @@ -1,6 +1,7 @@ from typing import Any, Dict, List, Optional, Tuple from fastapi import WebSocket + from jupyverse_api.auth import Auth, User USER = User() diff --git a/plugins/noauth/fps_noauth/main.py b/plugins/noauth/fps_noauth/main.py index 76509c6c..911a79f8 100644 --- a/plugins/noauth/fps_noauth/main.py +++ b/plugins/noauth/fps_noauth/main.py @@ -1,4 +1,5 @@ from asphalt.core import Component, Context + from jupyverse_api.auth import Auth from .backends import _NoAuth diff --git a/plugins/resource_usage/fps_resource_usage/main.py b/plugins/resource_usage/fps_resource_usage/main.py index 8eafa1bd..4cc3c2b7 100644 --- a/plugins/resource_usage/fps_resource_usage/main.py +++ b/plugins/resource_usage/fps_resource_usage/main.py @@ -1,6 +1,7 @@ from asphalt.core import Component, Context -from jupyverse_api.auth import Auth + from jupyverse_api.app import App +from jupyverse_api.auth import Auth from jupyverse_api.resource_usage import ResourceUsage, ResourceUsageConfig from .routes import _ResourceUsage diff --git a/plugins/resource_usage/fps_resource_usage/routes.py b/plugins/resource_usage/fps_resource_usage/routes.py index b0a5c355..736a24bc 100644 --- a/plugins/resource_usage/fps_resource_usage/routes.py +++ b/plugins/resource_usage/fps_resource_usage/routes.py @@ -1,5 +1,6 @@ import psutil from anyio import to_thread + from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.resource_usage import ResourceUsage, ResourceUsageConfig diff --git a/plugins/retrolab/fps_retrolab/main.py b/plugins/retrolab/fps_retrolab/main.py index 661751b1..38b4d342 100644 --- a/plugins/retrolab/fps_retrolab/main.py +++ b/plugins/retrolab/fps_retrolab/main.py @@ -1,9 +1,10 @@ from asphalt.core import Component, Context + from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.frontend import FrontendConfig -from jupyverse_api.retrolab import RetroLab from jupyverse_api.lab import Lab +from jupyverse_api.retrolab import RetroLab from .routes import _RetroLab diff --git a/plugins/retrolab/fps_retrolab/routes.py b/plugins/retrolab/fps_retrolab/routes.py index a5843b38..b35ba971 100644 --- a/plugins/retrolab/fps_retrolab/routes.py +++ b/plugins/retrolab/fps_retrolab/routes.py @@ -3,6 +3,7 @@ import retrolab # type: ignore from fastapi.staticfiles import StaticFiles + from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.frontend import FrontendConfig diff --git a/plugins/terminals/fps_terminals/main.py b/plugins/terminals/fps_terminals/main.py index 1ec474aa..93a00719 100644 --- a/plugins/terminals/fps_terminals/main.py +++ b/plugins/terminals/fps_terminals/main.py @@ -2,9 +2,10 @@ from typing import Type from asphalt.core import Component, Context + +from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.terminals import Terminals, TerminalServer -from jupyverse_api.app import App from .routes import _Terminals diff --git a/plugins/terminals/fps_terminals/routes.py b/plugins/terminals/fps_terminals/routes.py index 88e0fd2c..ca7d2f8d 100644 --- a/plugins/terminals/fps_terminals/routes.py +++ b/plugins/terminals/fps_terminals/routes.py @@ -3,6 +3,7 @@ from typing import Any, Dict, Type from fastapi import Response + from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.terminals import Terminal, Terminals, TerminalServer diff --git a/plugins/terminals/fps_terminals/server.py b/plugins/terminals/fps_terminals/server.py index 331c3fed..c086f8c6 100644 --- a/plugins/terminals/fps_terminals/server.py +++ b/plugins/terminals/fps_terminals/server.py @@ -7,6 +7,7 @@ import termios from fastapi import WebSocketDisconnect + from jupyverse_api.terminals import TerminalServer diff --git a/plugins/terminals/fps_terminals/win_server.py b/plugins/terminals/fps_terminals/win_server.py index 9aa3e259..f54f7f66 100644 --- a/plugins/terminals/fps_terminals/win_server.py +++ b/plugins/terminals/fps_terminals/win_server.py @@ -1,9 +1,10 @@ import asyncio import os -from jupyverse_api.terminals import TerminalServer from winpty import PTY # type: ignore +from jupyverse_api.terminals import TerminalServer + def open_terminal(command="C:\\Windows\\System32\\cmd.exe", columns=80, lines=24): env = "\0".join([f"{k}={v}" for k, v in os.environ.items()]) + "\0" diff --git a/plugins/webdav/fps_webdav/main.py b/plugins/webdav/fps_webdav/main.py index 014f6026..2e6c4662 100644 --- a/plugins/webdav/fps_webdav/main.py +++ b/plugins/webdav/fps_webdav/main.py @@ -1,4 +1,5 @@ from asphalt.core import Component, Context + from jupyverse_api.app import App from .config import WebDAVConfig diff --git a/plugins/webdav/fps_webdav/routes.py b/plugins/webdav/fps_webdav/routes.py index be142596..b31b1fc9 100644 --- a/plugins/webdav/fps_webdav/routes.py +++ b/plugins/webdav/fps_webdav/routes.py @@ -5,9 +5,9 @@ from pathlib import Path from asgi_middleware_static_file import ASGIMiddlewareStaticFile # type: ignore -from asgi_webdav.middleware.cors import ASGIMiddlewareCORS # type: ignore from asgi_webdav import __name__ as app_name # type: ignore from asgi_webdav import __version__ # type: ignore +from asgi_webdav.middleware.cors import ASGIMiddlewareCORS # type: ignore try: from asgi_webdav.config import ( # type: ignore @@ -25,7 +25,6 @@ from .config import WebDAVConfig - logger = logging.getLogger("webdav") diff --git a/plugins/webdav/tests/test_webdav.py b/plugins/webdav/tests/test_webdav.py index 9ec5d82e..dc6ed856 100644 --- a/plugins/webdav/tests/test_webdav.py +++ b/plugins/webdav/tests/test_webdav.py @@ -7,8 +7,8 @@ import pytest from anyio import to_thread from asphalt.core import Context -from jupyverse_api.main import JupyverseComponent +from jupyverse_api.main import JupyverseComponent COMPONENTS = { "app": {"type": "app"}, diff --git a/plugins/yjs/fps_yjs/main.py b/plugins/yjs/fps_yjs/main.py index 914cc3a1..eacd1b91 100644 --- a/plugins/yjs/fps_yjs/main.py +++ b/plugins/yjs/fps_yjs/main.py @@ -4,6 +4,7 @@ from typing import Optional from asphalt.core import Component, Context, context_teardown + from jupyverse_api.app import App from jupyverse_api.auth import Auth from jupyverse_api.contents import Contents diff --git a/plugins/yjs/fps_yjs/routes.py b/plugins/yjs/fps_yjs/routes.py index 148c5045..53064eb1 100644 --- a/plugins/yjs/fps_yjs/routes.py +++ b/plugins/yjs/fps_yjs/routes.py @@ -16,15 +16,16 @@ ) from jupyter_ydoc import ydocs as YDOCS from jupyter_ydoc.ybasedoc import YBaseDoc +from websockets.exceptions import ConnectionClosedOK +from ypy_websocket.websocket_server import WebsocketServer, YRoom +from ypy_websocket.ystore import SQLiteYStore, YDocNotFound +from ypy_websocket.yutils import YMessageType, YSyncMessageType + from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.contents import Contents from jupyverse_api.yjs import Yjs from jupyverse_api.yjs.models import CreateDocumentSession -from websockets.exceptions import ConnectionClosedOK -from ypy_websocket.websocket_server import WebsocketServer, YRoom -from ypy_websocket.ystore import SQLiteYStore, YDocNotFound -from ypy_websocket.yutils import YMessageType, YSyncMessageType YFILE = YDOCS["file"] AWARENESS = 1 diff --git a/pyproject.toml b/pyproject.toml index 3d6d48dc..0680ebb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,8 +105,8 @@ auth = ["noauth", "auth", "auth_fief", "auth_jupyterhub"] [tool.hatch.envs.dev.scripts] test = "pytest ./tests plugins/webdav/tests -v --reruns 5 --timeout=60" lint = [ - "black --line-length 100 jupyverse ./plugins", - "isort --profile=black jupyverse ./plugins", + "ruff format jupyverse jupyverse_api plugins", + "ruff check jupyverse jupyverse_api plugins --fix", ] typecheck0 = """mypy --no-incremental \ ./jupyverse_api \ @@ -131,8 +131,21 @@ serve = "mkdocs serve --dev-addr localhost:8000" [tool.check-manifest] ignore = [ ".*",] -[tool.black] -line-length = 100 +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + # "UP", + # flake8-bugbear + # "B", + # flake8-simplify + # "SIM", + # isort + "I", +] [tool.ruff] line-length = 100