1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +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
python_version = 3.11
# Exclude all .*/transports/.*/scripts/.* directories
exclude = .*/transports/.*/scripts/.*
# Exclude all .*/transports/.*/scripts/.* directories and all tests
exclude = (.*/transports/.*/scripts/.*|.*/tests/.*)
mypy_path = $MYPY_CONFIG_FILE_DIR/src
# 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
implicit_reexport = true

View File

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

View File

@ -28,21 +28,13 @@
"""
Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import typing
import collections.abc
import logging
from unittest import mock
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
if typing.TYPE_CHECKING:
from ...utils.test import UDSHttpResponse
logger = logging.getLogger(__name__)

View File

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

View File

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

View File

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