Closed ghadagd closed 1 year ago
pr sort of breaks some stuff dont merge yet if ur planning to
Hi. Thank you for making this PR.
However, I wouldn't recommend mixing comments and docstrings. After all, they are not the same.
It's like we're losing some information storing them this way.
Moreover, this functionality is already in the built-in ast
module. And it works perfectly.
Yes, you have to check (or handle exceptions) if a node is not a function, class, etc.
But still, this information is already there.
One can even make parse-unparse roundtrip and the docstring will be well-preserved.
>>> source = """
... def my_func():
... '''my docstring'''
... """
>>> print(ast.unparse(ast.parse(source)))
def my_func():
"""my docstring"""
One thing to consider: The major issue with the current implementation is that the library does not preserve comments after ast_comments.unparse
.
Mixing comments and docstrings will make it harder to separate one from another.
Hi. thanks for the very fast response
as I said this was more made for personal convenience so I could use .comments always and not need to have checks for docstrings etc.
If you think this isn't a good fit for the repo feel free to close it.
I made this more for personal convenience this doesn't need to be merged it just makes sure docstrings are also added to the "comments" field
Also added some tests for them