-
-
Notifications
You must be signed in to change notification settings - Fork 8
Feature: two-pass formatting of the tokens #173
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
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Looking at the conflicting formatters .... NumpydocSectionSpacingFormatter collides with ClosingQuotesFormatter NumpydocSectionSpacingFormatter '"""\n A docstring\n """' ClosingQuotesFormatter '"""A docstring"""' Looking at references Numpydoc differentiates between short summary and extended summary. where I think the correct out would be ... # CURRENT
'"""\n A docstring\n """'
# Expected
'"""A docstring\n\n """' Which for sure would be incompatible....
Extras:
|
(expectation left, actual right) and adds two newlines... because: INFO root:run.py:225 linewrap-full-docstring modified SplitSummaryAndDocstringFormatter adds the newline here: splits the summary incorrectly EditI think this is a feature and not a bug ...why: because it reconciles "max_summary_lines" and "max_line_length" ... since the summary first gets broken due to their max-length and then the space gets added because the max_summary_lines is 1 !!! |
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## main #173 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 23 +1
Lines 640 684 +44
=========================================
+ Hits 640 684 +44
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
4 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@DanielNoord I think I am at the point where some design decisions have to be made. |
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.
Thanks a lot @jspaezp there are many good changes in here.
I did a first review. Let me know what you think!
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
# CURRENT
'"""\n A docstring\n """'
# Expected
'"""A docstring"""' I think the Expected should be as above. This is what PEP256 mandates for single line docstrings. Would you wan to create an issue/PR to fix this?
Agreed. Perhaps we should switch the order around? So the wrapping is done before the splitting? |
This comment has been minimized.
This comment has been minimized.
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
4 similar comments
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
Looks much better as a context manager!
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
3 similar comments
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
tests/test_conflicting_formatters.py
Outdated
def patched_run(formatters: list[Formatter]) -> Generator[type[_Run], None, None]: | ||
"""Patches the _Run class to use only the provided formatters.""" | ||
old_formatters = _formatting.FORMATTERS | ||
try: |
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.
Why are we in a try
here?
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.
To be honest, its to be safe. it makes sure the cleanup happens if there are un-handled errors while yielding the patched run (which I'm not sure it it would affect all other tests).
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.
Hm, for now I'd say let's remove this. If any error occurred while patching formatters
(so while we run this test) the test (and test suite) will fail anyway. It's not necessary to guarantee a successful test suite run as if we raise we will fail anyway.
I did learn something new today though, that's always nice 😄
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.
Right on!
Alright, it works after removing it in 862356d
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
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'm going to give this one final review tomorrow when I'm "fresh", but I think we ironed out all the kinks 😄 🎉
Co-authored-by: J. Sebastian Paez <[email protected]>
Co-authored-by: J. Sebastian Paez <[email protected]>
Co-authored-by: J. Sebastian Paez <[email protected]>
Co-authored-by: J. Sebastian Paez <[email protected]>
862356d
to
5799b7f
Compare
According to the primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
@jspaezp I rebased and reordered the commit history to make it a bit cleaner. I also did some changes to capitalisation and changed changers
to be a set[str]
instead of list[str]
. If you agree with the current state of the PR I think we can merge 😄
those seem like good changes! |
Discussed here:
#169
Things to iron out:
#169 (comment)
Current error: