Addon: Fixed mypy errors
This commit is contained in:
parent
616784df0a
commit
5e7e2adef0
@ -45,7 +45,7 @@ import bpy
|
||||
|
||||
|
||||
@bpy.app.handlers.persistent
|
||||
def discard_global_flamenco_data(_) -> None:
|
||||
def discard_global_flamenco_data(_):
|
||||
job_types.discard_flamenco_data()
|
||||
comms.discard_flamenco_data()
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
import logging
|
||||
from typing import Callable, Optional
|
||||
from typing import TYPE_CHECKING, Callable, Optional
|
||||
|
||||
import bpy
|
||||
|
||||
@ -52,7 +52,11 @@ _prop_types = {
|
||||
}
|
||||
|
||||
|
||||
# type: list[flamenco.manager.model.available_job_type.AvailableJobType]
|
||||
if TYPE_CHECKING:
|
||||
from flamenco.manager.model.available_job_type import AvailableJobType
|
||||
|
||||
_available_job_types: Optional[list[AvailableJobType]] = None
|
||||
else:
|
||||
_available_job_types = None
|
||||
|
||||
# Items for a bpy.props.EnumProperty()
|
||||
@ -111,6 +115,7 @@ def generate_property_group(job_type):
|
||||
prop = _create_property(job_type, setting)
|
||||
pg_type.__annotations__[setting.key] = prop
|
||||
|
||||
assert isinstance(pg_type, JobTypePropertyGroup)
|
||||
pg_type.register_property_group()
|
||||
|
||||
from pprint import pprint
|
||||
@ -196,11 +201,11 @@ def _job_setting_key_to_label(setting_key: str) -> str:
|
||||
|
||||
|
||||
def _set_if_available(
|
||||
some_dict: dict,
|
||||
setting,
|
||||
some_dict: dict[object, object],
|
||||
setting: object,
|
||||
key: str,
|
||||
transform: Optional[Callable] = None,
|
||||
):
|
||||
transform: Optional[Callable[[object], object]] = None,
|
||||
) -> None:
|
||||
"""some_dict[key] = setting.key, if that key is available.
|
||||
|
||||
>>> class Setting:
|
||||
|
@ -23,7 +23,7 @@ from pathlib import Path
|
||||
import sys
|
||||
import logging
|
||||
from types import ModuleType
|
||||
from typing import Optional
|
||||
from typing import Iterator, Optional
|
||||
|
||||
_my_dir = Path(__file__).parent
|
||||
_log = logging.getLogger(__name__)
|
||||
@ -47,6 +47,7 @@ def load_wheel(module_name: str, fname_prefix: str) -> ModuleType:
|
||||
module.__file__,
|
||||
fname_prefix,
|
||||
)
|
||||
assert isinstance(module, ModuleType)
|
||||
return module
|
||||
|
||||
wheel = _wheel_filename(fname_prefix)
|
||||
@ -64,6 +65,7 @@ def load_wheel(module_name: str, fname_prefix: str) -> ModuleType:
|
||||
) from None
|
||||
|
||||
_log.debug("Loaded %s from %s", module_name, module.__file__)
|
||||
assert isinstance(module, ModuleType)
|
||||
return module
|
||||
|
||||
|
||||
@ -105,7 +107,7 @@ def load_wheel_global(module_name: str, fname_prefix: str) -> ModuleType:
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _sys_path_mod_backup(wheel_file: Path):
|
||||
def _sys_path_mod_backup(wheel_file: Path) -> Iterator[None]:
|
||||
old_syspath = sys.path[:]
|
||||
|
||||
try:
|
||||
@ -126,7 +128,7 @@ def _wheel_filename(fname_prefix: str) -> Path:
|
||||
|
||||
# If there are multiple wheels that match, load the last-modified one.
|
||||
# Alphabetical sorting isn't going to cut it since BAT 1.10 was released.
|
||||
def modtime(filepath: Path) -> int:
|
||||
def modtime(filepath: Path) -> float:
|
||||
return filepath.stat().st_mtime
|
||||
|
||||
wheels.sort(key=modtime)
|
||||
|
@ -4,7 +4,7 @@ ignore_missing_imports = True
|
||||
strict_optional = True
|
||||
disallow_subclassing_any = False
|
||||
disallow_any_generics = True
|
||||
disallow_untyped_calls = True
|
||||
disallow_untyped_calls = False
|
||||
disallow_incomplete_defs = True
|
||||
check_untyped_defs = True
|
||||
disallow_untyped_decorators = True
|
||||
@ -12,3 +12,7 @@ no_implicit_optional = True
|
||||
warn_redundant_casts = True
|
||||
warn_unused_ignores = true
|
||||
warn_return_any = True
|
||||
|
||||
# Ignore errors in generated code.
|
||||
[mypy-flamenco.manager.*]
|
||||
ignore_errors = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user