Skip to content

Commit

Permalink
fix edge case with unhashable types
Browse files Browse the repository at this point in the history
  • Loading branch information
demitryfly committed Jun 14, 2024
1 parent afceb60 commit 489ac0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions simple_ddl_parser/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import List, Tuple, Optional
from typing import List, Tuple, Optional, Union, Any

__all__ = [
"remove_par",
Expand All @@ -9,12 +9,14 @@
"get_table_id",
]

_parentheses = {'(', ')'}
_parentheses = ('(', ')')


def remove_par(p_list: List[str]) -> List[str]:
def remove_par(p_list: List[Union[str, Any]]) -> List[str]:
"""
Remove the parentheses from the given list
Warn: p_list may contain unhashable types for some unexplored reasons
"""
i = j = 0
while i < len(p_list):
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_find_first_unpair_closed_par(expression, expected_result):
(["A", "(", "(", "B", "C", "("], ["A", "B", "C"]),
(["A", ")", "B", ")", "(", "C"], ["A", "B", "C"]),
(["(", "A", ")", "B", "C", ")"], ["A", "B", "C"]),
([dict()], [dict()]), # Edge case (unhashable types)
]
)
def test_remove_par(expression, expected_result):
Expand Down

0 comments on commit 489ac0b

Please sign in to comment.