1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-03 01:17:56 +03:00

Fixed tests for pyright

This commit is contained in:
Adolfo Gómez García 2024-05-25 17:42:58 +02:00
parent 211cf4d5e6
commit 7281fa3494
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
6 changed files with 14 additions and 27 deletions

View File

@ -3,12 +3,12 @@
# mypy_django_plugin.main # mypy_django_plugin.main
python_version = 3.11 python_version = 3.11
# Exclude all .*/transports/.*/scripts/.* directories # Exclude all .*/transports/.*/scripts/.* directories and all tests
exclude = .*/transports/.*/scripts/.* exclude = (.*/transports/.*/scripts/.*|.*/tests/.*)
mypy_path = $MYPY_CONFIG_FILE_DIR/src mypy_path = $MYPY_CONFIG_FILE_DIR/src
# Call overload because ForeignKey fields are not being recognized with django-types # Call overload because ForeignKey fields are not being recognized with django-types
disable_error_code = import, no-any-return, misc, redundant-cast, call-overload disable_error_code = import, no-any-return, misc, redundant-cast, call-overload, no-untyped-call, no-untyped-call
strict = True strict = True
implicit_reexport = true implicit_reexport = true

View File

@ -30,7 +30,6 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
""" """
import typing import typing
import collections.abc import collections.abc
import functools
import logging import logging
from uds import models from uds import models

View File

@ -28,21 +28,13 @@
""" """
Author: Adolfo Gómez, dkmaster at dkmon dot com Author: Adolfo Gómez, dkmaster at dkmon dot com
""" """
import typing
import collections.abc
import logging import logging
from unittest import mock
from uds import models from uds import models
from uds.core.util import log
from ...utils import rest, random_ip_v4, random_ip_v6, random_mac from ...utils import rest
from ...fixtures import servers as servers_fixtures from ...fixtures import servers as servers_fixtures
if typing.TYPE_CHECKING:
from ...utils.test import UDSHttpResponse
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -30,9 +30,7 @@
""" """
Author: Adolfo Gómez, dkmaster at dkmon dot com Author: Adolfo Gómez, dkmaster at dkmon dot com
""" """
import time
import threading import threading
from tracemalloc import stop
import typing import typing
from unittest import mock from unittest import mock

View File

@ -30,8 +30,6 @@
Author: Adolfo Gómez, dkmaster at dkmon dot com Author: Adolfo Gómez, dkmaster at dkmon dot com
""" """
import typing import typing
import collections.abc
import logging
from ...utils.test import UDSTestCase from ...utils.test import UDSTestCase
from ...fixtures import authenticators as authenticators_fixtures from ...fixtures import authenticators as authenticators_fixtures

View File

@ -44,17 +44,17 @@ class PowerState(enum.StrEnum):
# Internal UNKNOW state # Internal UNKNOW state
UNKNOW = 'Unknow' UNKNOW = 'Unknow'
def is_running(self): def is_running(self) -> bool:
return self == PowerState.RUNNING return self == PowerState.RUNNING
def is_stopped(self): def is_stopped(self) -> bool:
return self in (PowerState.HALTED, PowerState.SUSPENDED) return self in (PowerState.HALTED, PowerState.SUSPENDED)
def is_suspended(self): def is_suspended(self) -> bool:
return self == PowerState.SUSPENDED return self == PowerState.SUSPENDED
@staticmethod @staticmethod
def from_str(value: str): def from_str(value: str) -> 'PowerState':
try: try:
return PowerState(value.capitalize()) return PowerState(value.capitalize())
except ValueError: except ValueError:
@ -80,17 +80,17 @@ class TaskStatus(enum.StrEnum):
# Internal UNKNOW state # Internal UNKNOW state
UNKNOW = 'unknow' UNKNOW = 'unknow'
def is_done(self): def is_done(self) -> bool:
return self in (TaskStatus.SUCCESS, TaskStatus.FAILURE, TaskStatus.CANCELLED) return self in (TaskStatus.SUCCESS, TaskStatus.FAILURE, TaskStatus.CANCELLED)
def is_success(self): def is_success(self) -> bool:
return self == TaskStatus.SUCCESS return self == TaskStatus.SUCCESS
def is_failure(self): def is_failure(self) -> bool:
return self == TaskStatus.FAILURE return self == TaskStatus.FAILURE
@staticmethod @staticmethod
def from_str(value: str): def from_str(value: str) -> 'TaskStatus':
try: try:
return TaskStatus(value.lower()) return TaskStatus(value.lower())
except ValueError: except ValueError:
@ -147,7 +147,7 @@ class StorageOperations(enum.StrEnum):
UNKNOW = 'unknow' UNKNOW = 'unknow'
@staticmethod @staticmethod
def from_str(value: str): def from_str(value: str) -> 'StorageOperations':
try: try:
return StorageOperations(value.lower()) return StorageOperations(value.lower())
except ValueError: except ValueError:
@ -277,7 +277,7 @@ class VMOperations(enum.StrEnum):
UNKNOW = 'unknow' UNKNOW = 'unknow'
@staticmethod @staticmethod
def from_str(value: str): def from_str(value: str) -> 'VMOperations':
try: try:
return VMOperations(value.lower()) return VMOperations(value.lower())
except ValueError: except ValueError: