From 5417d0a90cd9efa9667d294b436d425a45e3c303 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 12 Feb 2021 10:19:38 +0100 Subject: [PATCH] *: bump pyright version --- authentik/admin/api/metrics.py | 2 +- authentik/events/models.py | 1 - authentik/flows/transfer/importer.py | 4 ++-- authentik/outposts/controllers/k8s/base.py | 4 +++- authentik/policies/engine.py | 1 - authentik/root/celery.py | 6 +++--- azure-pipelines.yml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/authentik/admin/api/metrics.py b/authentik/admin/api/metrics.py index 3f2284980..333ea79f8 100644 --- a/authentik/admin/api/metrics.py +++ b/authentik/admin/api/metrics.py @@ -32,7 +32,7 @@ def get_events_per_1h(**filter_kwargs) -> List[Dict[str, int]]: .annotate(count=Count("pk")) .order_by("age_hours") ) - data = Counter({d["age_hours"]: d["count"] for d in result}) + data = Counter({int(d["age_hours"]): d["count"] for d in result}) results = [] _now = now() for hour in range(0, -24, -1): diff --git a/authentik/events/models.py b/authentik/events/models.py index 42af60e9c..f2b53a728 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -5,7 +5,6 @@ from typing import Optional, Union from uuid import uuid4 from django.conf import settings -from django.core.exceptions import ValidationError from django.db import models from django.http import HttpRequest from django.utils.translation import gettext as _ diff --git a/authentik/flows/transfer/importer.py b/authentik/flows/transfer/importer.py index 76e5bc2fe..c825c3e8c 100644 --- a/authentik/flows/transfer/importer.py +++ b/authentik/flows/transfer/importer.py @@ -2,7 +2,7 @@ from contextlib import contextmanager from copy import deepcopy from json import loads -from typing import Any, Dict +from typing import Any, Dict, Type from dacite import from_dict from dacite.exceptions import DaciteError @@ -90,7 +90,7 @@ class FlowImporter: def _validate_single(self, entry: FlowBundleEntry) -> BaseSerializer: """Validate a single entry""" model_app_label, model_name = entry.model.split(".") - model: SerializerModel = apps.get_model(model_app_label, model_name) + model: Type[SerializerModel] = apps.get_model(model_app_label, model_name) if not isinstance(model(), ALLOWED_MODELS): raise EntryInvalidError(f"Model {model} not allowed") diff --git a/authentik/outposts/controllers/k8s/base.py b/authentik/outposts/controllers/k8s/base.py index 5430e8915..f996e622f 100644 --- a/authentik/outposts/controllers/k8s/base.py +++ b/authentik/outposts/controllers/k8s/base.py @@ -2,6 +2,8 @@ from typing import TYPE_CHECKING, Generic, TypeVar from kubernetes.client import V1ObjectMeta +from kubernetes.client.models.v1_deployment import V1Deployment +from kubernetes.client.models.v1_pod import V1Pod from kubernetes.client.rest import ApiException from structlog.stdlib import get_logger @@ -12,7 +14,7 @@ if TYPE_CHECKING: from authentik.outposts.controllers.kubernetes import KubernetesController # pylint: disable=invalid-name -T = TypeVar("T") +T = TypeVar("T", V1Pod, V1Deployment) class ReconcileTrigger(SentryIgnoredException): diff --git a/authentik/policies/engine.py b/authentik/policies/engine.py index 149dc5b30..bd15af792 100644 --- a/authentik/policies/engine.py +++ b/authentik/policies/engine.py @@ -11,7 +11,6 @@ from sentry_sdk.tracing import Span from structlog.stdlib import BoundLogger, get_logger from authentik.core.models import User -from authentik.lib.utils.http import get_client_ip from authentik.policies.models import Policy, PolicyBinding, PolicyBindingModel from authentik.policies.process import PolicyProcess, cache_key from authentik.policies.types import PolicyRequest, PolicyResult diff --git a/authentik/root/celery.py b/authentik/root/celery.py index ad17921e0..20b515348 100644 --- a/authentik/root/celery.py +++ b/authentik/root/celery.py @@ -23,7 +23,7 @@ def config_loggers(*args, **kwags): # pylint: disable=unused-argument @after_task_publish.connect -def after_task_publish(sender=None, headers=None, body=None, **kwargs): +def after_task_publish_hook(sender=None, headers=None, body=None, **kwargs): """Log task_id after it was published""" info = headers if "task" in headers else body LOGGER.debug( @@ -33,14 +33,14 @@ def after_task_publish(sender=None, headers=None, body=None, **kwargs): # pylint: disable=unused-argument @task_prerun.connect -def task_prerun(task_id, task, *args, **kwargs): +def task_prerun_hook(task_id, task, *args, **kwargs): """Log task_id on worker""" LOGGER.debug("Task started", task_id=task_id, task_name=task.__name__) # pylint: disable=unused-argument @task_postrun.connect -def task_postrun(task_id, task, *args, retval=None, state=None, **kwargs): +def task_postrun_hook(task_id, task, *args, retval=None, state=None, **kwargs): """Log task_id on worker""" LOGGER.debug("Task finished", task_id=task_id, task_name=task.__name__, state=state) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 21c38cf9c..3adc8b401 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -93,7 +93,7 @@ stages: versionSpec: '3.9' - task: CmdLine@2 inputs: - script: npm install -g pyright@1.1.79 + script: npm install -g pyright@1.1.109 - task: CmdLine@2 inputs: script: |