-
Notifications
You must be signed in to change notification settings - Fork 105
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
Competing heuristics for 2+ argument statements that are one character short of fitting on a single line. #51
Comments
Hm... on second thought, (1) is somewhat intentional. While it may be possible to leave both unformatted it's a little confusing to think where in the stream of tokens we start/stop formatting. The way it is implemented now is "From the end of the As for (2): I get this with python 2.7.12 and 3.5.2:
|
About (1): I can see your point. However
Re (2): I ran that formatting on Ubuntu LTS 16.04 with the following. I can retry on other system configs in a couple days, see if the issue travels.
|
Yeah, I've got the same setup with ubuntu and python, and still get that formatting. I tried that with stdout as output and with Can you paste the command you used? I'll see if I can replicate the behavior. |
Ok, I've tried it on Ubuntu and Windows, 0.4.0rc1 and 0.4.0, pip-installed and tarball. I consistently get the same weird formatting on that set() command, on every tested platform with 0.4.0. My 0.4.0* results are all identical, see 1 2 3 I appreciate you're not able to repro mine, but I'm not able to repro yours! My 0.4.0* tests all begin with the 0.3.6 baseline, as shown in my git history. Here are the invocation scripts I used in each test. (The 0.3.6 is slightly different, to workaround the comment bug)... These 0.4.0* are all basically identical... |
Trying another platform, I also get the same consistently weird formatting w 0.4.0 pip on Raspbian. |
The difference in behavior is apparently due to your |
Ok, so note that
Should be the preferred formatting. I'm not sure why it's passing over that one. I'll update when I figure out what's going on. |
Ok, I see the problem. It has to do with the fact that everything "almost" fits on one line. It is just one character short. There are two heuristics that come into play in this situation and they seem to conflict. Note to self for how to fix:
|
As a temporary workaround, I suggest adding a blank comment at the end:
|
Cool! Thanks very much for the detective work. |
* Add algorithm order config option * Add user specified fence regex config option * Add user specified ruler regex config option * Add config option to disable comment formatting altogether * Fix get_config bug in ``__main__`` * Fix missing elseif command specification * Fix missing elseif/else paren spacing when specified * Add enable_markup config option * Fix kwargstack early breaking in conditionals * Add some notes for developers. * Add warning if formatter is inactive at the end of a print * Add config options to preserve first comment or any matching a regex Closed issues: * Fixes #34 - if conditions with many elements * Closes #35 - break_before_args * Resolves #42 - user specified string for fencing * Resolves #43 - allow custom string for rulers * Fixes #45 - config file not loaded properly * Fixes #51 - competing herustics for 2+ argument statements * Resolves #60 - option to not reflow initial comment block * Resolves #61 - add non-builtin commands * Fixes #63 - elseif like if * Resolves #65 - warn if off doesn't have corresponding on * Closes #67 - global option to not format comments * Fixes #68 - seperate-ctrl-name-with-space
* Add visual studio code extension * Add algorithm order config option * Add user specified fence regex config option * Add user specified ruler regex config option * Add config option to disable comment formatting altogether * Fix get_config bug in ``__main__`` * Fix missing elseif command specification * Fix missing elseif/else paren spacing when specified * Add enable_markup config option * Fix kwargstack early breaking in conditionals * Add some notes for developers. * Add warning if formatter is inactive at the end of a print * Add config options to preserve first comment or any matching a regex Closed issues: * Fixes #34 - if conditions with many elements * Closes #35 - break_before_args * Resolves #42 - user specified string for fencing * Resolves #43 - allow custom string for rulers * Fixes #45 - config file not loaded properly * Fixes #51 - competing herustics for 2+ argument statements * Resolves #60 - option to not reflow initial comment block * Resolves #61 - add non-builtin commands * Fixes #63 - elseif like if * Resolves #65 - warn if off doesn't have corresponding on * Closes #67 - global option to not format comments * Fixes #68 - seperate-ctrl-name-with-space
Thanks very much!
The text was updated successfully, but these errors were encountered: