Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def is_literal_or_name(value: str) -> bool:
try:
ast.literal_eval(value)
return True
except (SyntaxError, ValueError):
except (SyntaxError, TypeError, ValueError):
pass

if value.strip() in ["dict()", "list()", "set()"]:
Expand Down
5 changes: 5 additions & 0 deletions test_autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,11 @@ def test_is_literal_or_name(self) -> None:
self.assertFalse(autoflake.is_literal_or_name("xyz.prop"))
self.assertFalse(autoflake.is_literal_or_name(" "))

def test_is_literal_or_name_with_unhashable_types(self) -> None:
"""Should not crash on set literals containing unhashable types."""
self.assertFalse(autoflake.is_literal_or_name("{{}}"))
self.assertFalse(autoflake.is_literal_or_name("{[]}"))

def test_is_python_file(self) -> None:
self.assertTrue(
autoflake.is_python_file(
Expand Down
Loading