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
+4
View File
@@ -20,6 +20,7 @@
import logging
import pathlib
import unittest
from typing import Optional
from blender_asset_tracer import blendfile
@@ -29,6 +30,9 @@ logging.basicConfig(
class AbstractBlendFileTest(unittest.TestCase):
blendfiles: pathlib.Path
bf: Optional[blendfile.BlendFile]
@classmethod
def setUpClass(cls):
cls.blendfiles = pathlib.Path(__file__).with_name("blendfiles")
+7
View File
@@ -19,6 +19,7 @@
# (c) 2019, Blender Foundation - Sybren A. Stüvel
import pathlib
import platform
from typing import Dict
import responses
@@ -29,6 +30,12 @@ httpmock = responses.RequestsMock()
class ShamanTransferTest(AbstractBlendFileTest):
test_file1: pathlib.Path
test_file2: pathlib.Path
expected_checksums: Dict[pathlib.Path, str]
file_sizes: Dict[pathlib.Path, int]
packed_names: Dict[pathlib.Path, str]
@classmethod
def setUpClass(cls):
super().setUpClass()
+5 -4
View File
@@ -2,6 +2,7 @@ import collections
import logging
import sys
import typing
from typing import Optional
from blender_asset_tracer import trace, blendfile
from blender_asset_tracer.blendfile import dna
@@ -65,7 +66,7 @@ class AssetHoldingBlocksTest(AbstractTracerTest):
class DepsTest(AbstractTracerTest):
@staticmethod
def field_name(field: dna.Field) -> typing.Optional[str]:
def field_name(field: Optional[dna.Field]) -> typing.Optional[str]:
if field is None:
return None
return field.name.name_full.decode()
@@ -88,18 +89,18 @@ class DepsTest(AbstractTracerTest):
exp = expects.get(dep.block_name, None)
if isinstance(exp, (set, list)):
self.assertIn(actual, exp, msg="for block %s" % dep.block_name)
self.assertIn(actual, exp, msg="for block %r" % dep.block_name)
exp.remove(actual)
if not exp:
# Don't leave empty sets in expects.
del expects[dep.block_name]
elif exp is None:
self.assertIsNone(
actual, msg="unexpected dependency of block %s" % dep.block_name
actual, msg="unexpected dependency of block %r" % dep.block_name
)
del expects[dep.block_name]
else:
self.assertEqual(exp, actual, msg="for block %s" % dep.block_name)
self.assertEqual(exp, actual, msg="for block %r" % dep.block_name)
del expects[dep.block_name]
# All expected uses should have been seen.