🐛 fix(directory_reader.py): handle SyntaxError when checking if type hint is used but not imported

🔍 refactor(directory_reader.py): improve error handling when checking if type hint is used but not imported
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-31 21:11:41 -03:00
commit 99ed85c03c

View file

@ -176,9 +176,14 @@ class DirectoryReader:
"""
Check if a type hint is used but not imported in the given code.
"""
return self._is_type_hint_used_in_args(
type_hint_name, code
) and not self._is_type_hint_imported(type_hint_name, code)
try:
return self._is_type_hint_used_in_args(
type_hint_name, code
) and not self._is_type_hint_imported(type_hint_name, code)
except SyntaxError:
# Returns True if there's something wrong with the code
# TODO : Find a better way to handle this
return True
def process_file(self, file_path):
"""