mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-30 17:41:54 +08:00
new typing style
This commit is contained in:
@@ -20,8 +20,6 @@
|
||||
# ========================================================================== #
|
||||
|
||||
|
||||
from typing import Type
|
||||
|
||||
from .. import BasePlugin
|
||||
from .. import get_plugin_class
|
||||
|
||||
@@ -36,5 +34,5 @@ class BaseAuthService(BasePlugin):
|
||||
|
||||
|
||||
# =====
|
||||
def get_auth_service_class(name: str) -> Type[BaseAuthService]:
|
||||
def get_auth_service_class(name: str) -> type[BaseAuthService]:
|
||||
return get_plugin_class("auth", name) # type: ignore
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
# ========================================================================== #
|
||||
|
||||
|
||||
from typing import Dict
|
||||
|
||||
import passlib.apache
|
||||
|
||||
from ...yamlconf import Option
|
||||
@@ -37,7 +35,7 @@ class Plugin(BaseAuthService):
|
||||
self.__path = path
|
||||
|
||||
@classmethod
|
||||
def get_plugin_options(cls) -> Dict:
|
||||
def get_plugin_options(cls) -> dict:
|
||||
return {
|
||||
"file": Option("/etc/kvmd/htpasswd", type=valid_abs_file, unpack_as="path"),
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
# ========================================================================== #
|
||||
|
||||
|
||||
from typing import Dict
|
||||
from typing import Optional
|
||||
|
||||
import aiohttp
|
||||
import aiohttp.web
|
||||
|
||||
@@ -57,10 +54,10 @@ class Plugin(BaseAuthService):
|
||||
self.__passwd = passwd
|
||||
self.__timeout = timeout
|
||||
|
||||
self.__http_session: Optional[aiohttp.ClientSession] = None
|
||||
self.__http_session: (aiohttp.ClientSession | None) = None
|
||||
|
||||
@classmethod
|
||||
def get_plugin_options(cls) -> Dict:
|
||||
def get_plugin_options(cls) -> dict:
|
||||
return {
|
||||
"url": Option("http://localhost/auth"),
|
||||
"verify": Option(True, type=valid_bool),
|
||||
@@ -102,7 +99,7 @@ class Plugin(BaseAuthService):
|
||||
|
||||
def __ensure_http_session(self) -> aiohttp.ClientSession:
|
||||
if not self.__http_session:
|
||||
kwargs: Dict = {}
|
||||
kwargs: dict = {}
|
||||
if self.__user:
|
||||
kwargs["auth"] = aiohttp.BasicAuth(login=self.__user, password=self.__passwd)
|
||||
if not self.__verify:
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
import asyncio
|
||||
import pwd
|
||||
|
||||
from typing import List
|
||||
from typing import Dict
|
||||
|
||||
import pam
|
||||
|
||||
from ...yamlconf import Option
|
||||
@@ -45,8 +42,8 @@ class Plugin(BaseAuthService):
|
||||
def __init__( # pylint: disable=super-init-not-called
|
||||
self,
|
||||
service: str,
|
||||
allow_users: List[str],
|
||||
deny_users: List[str],
|
||||
allow_users: list[str],
|
||||
deny_users: list[str],
|
||||
allow_uids_at: int,
|
||||
) -> None:
|
||||
|
||||
@@ -58,7 +55,7 @@ class Plugin(BaseAuthService):
|
||||
self.__lock = asyncio.Lock()
|
||||
|
||||
@classmethod
|
||||
def get_plugin_options(cls) -> Dict:
|
||||
def get_plugin_options(cls) -> dict:
|
||||
return {
|
||||
"service": Option("login"),
|
||||
"allow_users": Option([], type=valid_users_list),
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
import io
|
||||
|
||||
from typing import Dict
|
||||
|
||||
import pyrad.client
|
||||
import pyrad.packet
|
||||
import pyrad.dictionary
|
||||
@@ -413,7 +411,7 @@ class Plugin(BaseAuthService):
|
||||
self.__timeout = timeout
|
||||
|
||||
@classmethod
|
||||
def get_plugin_options(cls) -> Dict:
|
||||
def get_plugin_options(cls) -> dict:
|
||||
return {
|
||||
"host": Option("localhost", type=valid_ip_or_host),
|
||||
"port": Option(1812, type=valid_port),
|
||||
|
||||
Reference in New Issue
Block a user