root: early spring clean for linting (#8498)
* remove pyright Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove pylint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * replace pylint with ruff Signed-off-by: Jens Langhammer <jens@goauthentik.io> * ruff fix Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix UP038 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix DJ012 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix default arg Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix UP031 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename stage type to view Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix DJ008 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix remaining upgrade Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix PLR2004 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix B904 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix PLW2901 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix remaining issues Signed-off-by: Jens Langhammer <jens@goauthentik.io> * prevent ruff from breaking the code Signed-off-by: Jens Langhammer <jens@goauthentik.io> * stages/prompt: refactor field building Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fully remove isort Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
		| @ -2,16 +2,15 @@ | ||||
|  | ||||
| from datetime import datetime, timedelta | ||||
| from time import perf_counter | ||||
| from typing import Any, Optional | ||||
| from typing import Any | ||||
|  | ||||
| from django.utils.timezone import now | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
| from structlog.stdlib import get_logger | ||||
| from tenant_schemas_celery.task import TenantTask | ||||
|  | ||||
| from authentik.events.models import Event, EventAction | ||||
| from authentik.events.models import Event, EventAction, TaskStatus | ||||
| from authentik.events.models import SystemTask as DBSystemTask | ||||
| from authentik.events.models import TaskStatus | ||||
| from authentik.events.utils import sanitize_item | ||||
| from authentik.lib.utils.errors import exception_to_string | ||||
|  | ||||
| @ -27,10 +26,10 @@ class SystemTask(TenantTask): | ||||
|     _status: TaskStatus | ||||
|     _messages: list[str] | ||||
|  | ||||
|     _uid: Optional[str] | ||||
|     _uid: str | None | ||||
|     # Precise start time from perf_counter | ||||
|     _start_precise: Optional[float] = None | ||||
|     _start: Optional[datetime] = None | ||||
|     _start_precise: float | None = None | ||||
|     _start: datetime | None = None | ||||
|  | ||||
|     def __init__(self, *args, **kwargs) -> None: | ||||
|         super().__init__(*args, **kwargs) | ||||
| @ -60,14 +59,13 @@ class SystemTask(TenantTask): | ||||
|         self._start = now() | ||||
|         return super().before_start(task_id, args, kwargs) | ||||
|  | ||||
|     def db(self) -> Optional[DBSystemTask]: | ||||
|     def db(self) -> DBSystemTask | None: | ||||
|         """Get DB object for latest task""" | ||||
|         return DBSystemTask.objects.filter( | ||||
|             name=self.__name__, | ||||
|             uid=self._uid, | ||||
|         ).first() | ||||
|  | ||||
|     # pylint: disable=too-many-arguments | ||||
|     def after_return(self, status, retval, task_id, args: list[Any], kwargs: dict[str, Any], einfo): | ||||
|         super().after_return(status, retval, task_id, args, kwargs, einfo=einfo) | ||||
|         if not self._status: | ||||
| @ -97,7 +95,6 @@ class SystemTask(TenantTask): | ||||
|             }, | ||||
|         ) | ||||
|  | ||||
|     # pylint: disable=too-many-arguments | ||||
|     def on_failure(self, exc, task_id, args, kwargs, einfo): | ||||
|         super().on_failure(exc, task_id, args, kwargs, einfo=einfo) | ||||
|         if not self._status: | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jens L
					Jens L