mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
Fix errors reported by mypy
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
6835a569a5
commit
20f713e6f7
3 changed files with 15 additions and 13 deletions
|
|
@ -53,7 +53,7 @@ class Auth: # export
|
||||||
self.__conf = conf
|
self.__conf = conf
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def _access(self, what: str, access_type: Optional[Access]=None, who: Optional[Union[User|Group]]=None) -> bool:
|
def _access(self, what: str, access_type: Optional[Access], who: User|Group|None) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
from ... import log
|
from ...log import *
|
||||||
from ... import Config
|
from ... import Config
|
||||||
from .. import Access
|
from .. import Access
|
||||||
from .. import Auth as AuthBase
|
from .. import Auth as AuthBase
|
||||||
|
|
@ -23,25 +23,27 @@ class User(UserBase):
|
||||||
def __init__(self, auth: AuthBase, name: str):
|
def __init__(self, auth: AuthBase, name: str):
|
||||||
self.__name = name
|
self.__name = name
|
||||||
self.__auth = auth
|
self.__auth = auth
|
||||||
self.__groups = None
|
self.__groups: Optional[list[GroupBase]] = None
|
||||||
|
|
||||||
def _name(self) -> str:
|
def _name(self) -> str:
|
||||||
return self.__name
|
return self.__name
|
||||||
|
|
||||||
def _groups(self) -> list[Group]:
|
def _groups(self) -> list[GroupBase]:
|
||||||
if self.__groups is None:
|
if self.__groups is None:
|
||||||
for name in conf['user.' + name + '.groups']:
|
name: str = ''
|
||||||
ret[name] = Group(self, name)
|
ret: list[GroupBase] = []
|
||||||
|
for name in self.__auth.conf['user.' + name + '.groups']:
|
||||||
|
ret.append(Group(self.__auth, name))
|
||||||
self.__groups = ret
|
self.__groups = ret
|
||||||
self.__groups = ret
|
return self.__groups
|
||||||
|
|
||||||
class Auth(AuthBase): # export
|
class Auth(AuthBase): # export
|
||||||
|
|
||||||
def __init__(self, conf: Config):
|
def __init__(self, conf: Config):
|
||||||
self.__conf = conf
|
self.__conf = conf
|
||||||
self.__users = None
|
self.__users: Optional[dict[str, User]] = None
|
||||||
self.__groups = None
|
self.__groups = None
|
||||||
self.__current_user = None
|
self.__current_user: User|None = None
|
||||||
|
|
||||||
def _user(self, name_) -> User:
|
def _user(self, name_) -> User:
|
||||||
if self.__users is None:
|
if self.__users is None:
|
||||||
|
|
@ -51,8 +53,8 @@ class Auth(AuthBase): # export
|
||||||
self.__users = ret
|
self.__users = ret
|
||||||
return self.__users[name_]
|
return self.__users[name_]
|
||||||
|
|
||||||
def _access(self, what: str, access_type: Optional[Access]=None, who: Optional[Union[User|Group]]=None) -> bool:
|
def _access(self, what: str, access_type: Optional[Access], who: User|GroupBase|None) -> bool: # type: ignore
|
||||||
slog(log.WARNING, f'Returning False for {access_type} access to resource {what} by {who}')
|
slog(WARNING, f'Returning False for {access_type} access to resource {what} by {who}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _current_user(self) -> User:
|
def _current_user(self) -> User:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class QueryResult(abc.ABC): # export
|
||||||
return self.__query
|
return self.__query
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def session(self) -> DataBase:
|
def session(self) -> Session:
|
||||||
return self.__session
|
return self.__session
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -58,5 +58,5 @@ class QueryResult(abc.ABC): # export
|
||||||
# -- pure virtuals
|
# -- pure virtuals
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def _cast(self, session: Session, res_type: ResType, **kwargs) -> Union[Any|list[Any]]:
|
def _cast(self, res_type: ResType, **kwargs) -> Union[Any|list[Any]]:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue