-
Notifications
You must be signed in to change notification settings - Fork 10
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
Extract _build_row_lengths_offsets function #117
Conversation
73127cb
to
85c7bf6
Compare
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.
Sorry for delay. Have difficulty getting free time when I also have internet access.
After much puzzling, I think I've figured out what on earth I was thinking with the original implementation.
I think the missing test case is:
def test_split_class_with_bases():
actual = _split_class("class A(\n B,\n):pass")
expected = "class A(\n B,\n):", [" pass"]
assert actual == expected
Here the line with class...
on it is not the same as the line that ends the class head.
With this change we get:
'class A(', [' B,\n):pass']
Sadly I don't think there is a node for the trailing bracket or colon so I don't know what can be done.
59e2036
to
51296f0
Compare
I totally appreciate your patience in reviewing this and not letting me almost mess it up! :- ) I've updated the PR with a smaller refactoring, adding the test case that you mentioned and also fixing the recent error with the coverage check. |
@@ -30,6 +30,10 @@ | |||
def _nodes_types( | |||
node_type: type[ast.AST] = ast.AST, | |||
) -> Iterable[type[ast.AST]]: | |||
# coverage package adds a coverage.parser.NodeList subclass |
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.
That's just naughty. Why on earth does it do that?
Thanks. Mind restoring the two test cases you had in before? They looked worthwhile. |
for the more complex cases that cover the implementation using tokenize.
Was failing with tests/test_ast.py:71: in <module> @parametrize_nodes() tests/test_ast.py:60: in parametrize_nodes nodes = [_instantiate_node(node_type) for node_type in node_types] tests/test_ast.py:55: in _instantiate_node return node_type(*([""] * len(node_type._fields))) E TypeError: NodeList.__init__() missing 1 required positional argument: 'body' coverage package adds a coverage.parser.NodeList subclass. See nedbat/coveragepy@0accb68
51296f0
to
51354eb
Compare
Sure, done! |
Pull Request Test Coverage Report for Build 9035218786Details
💛 - Coveralls |
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.
Thank you very much. Very happy to take any other improvements that might tickle your fancy.
No description provided.