Cleanup: fix mypy errors

This mostly handles a mypy change where implicit optionals (i.e. things
like `size: int = None`) are no longer allowed.

No functional changes.
This commit is contained in:
Sybren A. Stüvel
2023-11-02 14:46:38 +01:00
parent b3fb7845c3
commit f9bc6f2d08
7 changed files with 26 additions and 10 deletions
+2 -1
View File
@@ -22,6 +22,7 @@
import logging
import os
import typing
from typing import Optional
from . import header, exceptions
@@ -104,7 +105,7 @@ class Struct:
log = log.getChild("Struct")
def __init__(self, dna_type_id: bytes, size: int = None) -> None:
def __init__(self, dna_type_id: bytes, size: Optional[int] = None) -> None:
"""
:param dna_type_id: name of the struct in C, like b'AlembicObjectPath'.
:param size: only for unit tests; typically set after construction by
+2 -1
View File
@@ -25,6 +25,7 @@ import logging
import pathlib
import queue
import typing
from typing import Optional
import blender_asset_tracer.trace.progress
@@ -134,7 +135,7 @@ class ThreadSafeCallback(Callback):
def missing_file(self, filename: pathlib.Path) -> None:
self._queue(self.wrapped.missing_file, filename)
def flush(self, timeout: float = None) -> None:
def flush(self, timeout: Optional[float] = None) -> None:
"""Call the queued calls, call this in the main thread."""
while True:
+2 -1
View File
@@ -25,6 +25,7 @@ import queue
import threading
import time
import typing
from typing import Optional
from . import progress
@@ -186,7 +187,7 @@ class FileTransferer(threading.Thread, metaclass=abc.ABCMeta):
if self.done.is_set():
return
def join(self, timeout: float = None) -> None:
def join(self, timeout: Optional[float] = None) -> None:
"""Wait for the transfer to finish/stop."""
if timeout:
+4 -3
View File
@@ -21,6 +21,7 @@ import functools
import logging
import pathlib
import typing
from typing import Optional
from blender_asset_tracer import blendfile, bpathlib
from blender_asset_tracer.blendfile import dna
@@ -57,9 +58,9 @@ class BlockUsage:
block: blendfile.BlendFileBlock,
asset_path: bpathlib.BlendPath,
is_sequence: bool = False,
path_full_field: dna.Field = None,
path_dir_field: dna.Field = None,
path_base_field: dna.Field = None,
path_full_field: Optional[dna.Field] = None,
path_dir_field: Optional[dna.Field] = None,
path_base_field: Optional[dna.Field] = None,
block_name: bytes = b"",
) -> None:
if block_name: