Skip to content

Commit

Permalink
type checker changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 30, 2023
1 parent 13cae2a commit 713bbb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions spinn_utilities/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ def __verify_method_arguments(self, method: Method):
raise AttributeError(
f"Default arguments don't match {self._override_name}")

@staticmethod
def to_str(type_value):
if isinstance(type_value, type):
type_value = type_value.__name__
else:
type_value = str(type_value)
return type_value.removeprefix("typing.")

def __is_similar_type(self, method_type, super_type, arg):
# easiest case they are the same
if method_type == super_type:
Expand All @@ -142,10 +150,8 @@ def __is_similar_type(self, method_type, super_type, arg):
# If either came from annotations
if isinstance(method_type, str) or isinstance(super_type, str):
# convert types to str
if isinstance(method_type, type):
method_type = method_type.__name__
if isinstance(super_type, type):
super_type = super_type.__name__
method_type = self.to_str(method_type)
super_type = self.to_str(super_type)
# hopefully they are equal now
if method_type == super_type:
return True
Expand Down
2 changes: 1 addition & 1 deletion spinn_utilities/package_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def load_modules(
if module in exclusions:
print("SKIPPING " + module)
continue
print(module)
#print(module)
try:
__import__(module)
except Exception: # pylint: disable=broad-except
Expand Down

0 comments on commit 713bbb7

Please sign in to comment.