-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor utils, add tests, move exceptions into separate module #264
Merged
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5fd2aa8
perform some refactorings
demitryfly 1d4272d
clean up debugging code
demitryfly c1a6e0c
refactor table_data.py
demitryfly d32f7aa
improve test
demitryfly 427cca6
refactor check_spec
demitryfly afceb60
fix tests (fix import)
demitryfly 489ac0b
fix edge case with unhashable types
demitryfly 168eb00
fix typing
demitryfly 211249f
Add tests
demitryfly bf8be31
fix docstr
demitryfly 768a425
revert rename: DDLParserError -> SimpleDDLParserException
demitryfly 48446ae
add backward compatibility import
demitryfly e2871fe
fix DDLParserError for backward compatibility
demitryfly 0bea915
fix DDLParserError for backward compatibility
demitryfly 5ebab6f
one more fix
demitryfly 1fae5ba
refactor a bit
demitryfly 2bc0075
Merge branch 'main' into some-refactorings-1
xnuinside d2413d5
Merge branch 'main' into some-refactorings-1
xnuinside File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
__all__ = [ | ||
"DDLParserError", | ||
] | ||
|
||
|
||
class DDLParserError(Exception): | ||
""" Base exception in simple ddl parser library """ | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
import utils | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"expression, expected_result", | ||
[ | ||
(")", 0), | ||
(")()", 0), | ||
("())", 2), | ||
("()())", 4), | ||
("", None), | ||
("text", None), | ||
("()", None), | ||
("(balanced) (brackets)", None), | ||
("(not)) (balanced) (brackets", 5) | ||
] | ||
) | ||
def test_find_first_unpair_closed_par(expression, expected_result): | ||
assert utils.find_first_unpair_closed_par(expression) == expected_result | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"expression, expected_result", | ||
[ | ||
([], []), | ||
(["("], []), | ||
([")"], []), | ||
(["(", ")"], []), | ||
(["(", ")"], []), | ||
(["(", "A"], ["A"]), | ||
(["A", ")"], ["A"]), | ||
(["(", "A", ")"], ["A"]), | ||
(["A", ")", ")"], ["A"]), | ||
(["(", "(", "A"], ["A"]), | ||
(["A", "B", "C"], ["A", "B", "C"]), | ||
(["A", "(", "(", "B", "C", "("], ["A", "B", "C"]), | ||
(["A", ")", "B", ")", "(", "C"], ["A", "B", "C"]), | ||
(["(", "A", ")", "B", "C", ")"], ["A", "B", "C"]), | ||
] | ||
) | ||
def test_remove_par(expression, expected_result): | ||
assert utils.remove_par(expression) == expected_result |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, if someone uses this exception in their code (to catch it in
try-except
, for instance). If, it is possible, then it is more correct to make an alias and deprecate it officially.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not rename exceptions, I didn’t merge it because of those changes. Sorry for long delay with review. Didn’t have any time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Let me know, it there are something else to be fixed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, there is no reason to exist both
SimpleDDLParserException
andDDLParserError
exception type. Only backward compatibility. (If I understood correctly)