Jelle Zijlstra
455de7703e
Fix another f-string regression ( #4339 )
2024-04-27 01:24:20 -07:00
Jelle Zijlstra
e4aaa8a994
Fix incorrect f-string tokenization ( #4332 )
2024-04-25 16:45:46 -07:00
Jelle Zijlstra
ba88fc372e
Simplify string tokenization regexes ( #4331 )
2024-04-24 23:11:31 -07:00
Jelle Zijlstra
3f0f8f1956
Support PEP 696 ( #4327 )
2024-04-23 22:08:37 -07:00
peterkra25
1354be2525
Add support to style function definitions with newlines before function stubs ( #4318 )
...
* Add support to style function definitions containing newlines before function stubs
* Relocated implementation for removal of newlines before function stubs with added tests for comments
---------
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-04-23 19:19:56 -07:00
Tushar Sadhwani
f4b644b82f
Prevent wrapping of multiline fstrings in parens ( #4325 )
2024-04-23 14:16:47 -07:00
Tushar Sadhwani
551ede2825
Add PEP 701 support ( #3822 )
...
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-04-22 08:19:19 -07:00
cobalt
13bd0925eb
fix: Stop moving multiline strings to a new line unless inside brackets ( #4289 )
...
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-03-22 20:11:01 -06:00
rdrll
f78b15712a
Fix formatting for if
clauses in match-case
blocks ( #4269 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-03-16 07:38:07 -07:00
Samson Umezulike
7b5a657285
Fix --line-ranges behavior when ranges are at EOF ( #4273 )
...
Fixes #4264
2024-03-15 11:18:47 -07:00
cobalt
e4bfedbec2
fix: Don't move comments while splitting delimiters ( #4248 )
...
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-03-01 07:02:56 -08:00
cobalt
8af439407c
fix: Don't remove comments along with parens ( #4218 )
...
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-02-12 06:27:50 -08:00
Logan Hunt
dab37a6a11
Remove redundant parentheses in case
statement if
guards ( #4214 )
...
A follow up to #4024 but for `if` guards in `case` statements. I noticed this
when #4024 was made stable, and noticed I had some code that had extra parens
around the `if` guard.
2024-02-07 06:55:02 -08:00
Seung Wan Yoo
32230e6f5c
fix: bug where the doublestar operation had inconsistent formatting. ( #4154 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-02-05 05:33:11 -08:00
Brandon J
7edb50f5a0
fix: additional newline added to docstring when the previous line length is less than the line length limit minus 1 ( #4185 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-02-05 04:56:07 -08:00
Jelle Zijlstra
9728b8e9b8
Move hug_parens_with_braces_and_square_brackets into the unstable style ( #4198 )
...
Primarily because of #4036 (a crash) but also because of the feedback
in #4098 and #4099 .
2024-02-01 21:58:51 -08:00
cobalt
8bf04549ff
Consistently add trailing comma on typed parameters ( #4164 )
...
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-01-27 13:55:22 -08:00
Jelle Zijlstra
4f47cac192
Add --unstable flag ( #4096 )
2024-01-25 17:00:47 -08:00
Daniel Krzeminski
bccec8adfb
Show warning on invalid toml configuration ( #4165 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-01-25 16:41:37 -08:00
cobalt
a5196e6f1f
fix: Don't normalize whitespace before fmt:skip comments ( #4146 )
...
Signed-off-by: RedGuy12 <paul@reid-family.org>
2024-01-25 01:31:49 -08:00
Jelle Zijlstra
59b9d858a3
Create the 2024 stable style ( #4106 )
2024-01-24 17:06:14 -08:00
Shantanu
995e4ada14
Fix unnecessary nesting when wrapping long dict ( #4135 )
...
Fixes #4129
2024-01-19 17:13:26 -08:00
cobalt
9a331d606f
fix: Don't allow unparenthesizing walruses ( #4155 )
...
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Signed-off-by: RedGuy12 <paul@reid-family.org>
2024-01-17 11:04:15 -08:00
Shantanu
e11eaf2f44
Make blank_line_after_nested_stub_class
work for methods ( #4141 )
...
Fixes #4113
Authored by dhruvmanila
2024-01-01 20:14:57 -08:00
Shantanu
b1d17ef9a2
Fix comment handling when parenthesising conditional expressions ( #4134 )
...
Fixes #3555
2024-01-01 17:55:11 -08:00
Shantanu
4ceed0b958
Remove is_function_or_class helper footgun ( #4133 )
...
This is a no-op change.
That function was not a good way to tell if something is a function or a
class, since it basically only worked for async functions by accident
(the parent of a suite / simple_stmt of async function body is a
funcdef).
2024-01-01 17:36:49 -08:00
Shantanu
8e0a9dee1b
Remove empty lines before docstrings in async functions ( #4132 )
2024-01-01 16:56:39 -08:00
Shantanu
fe3376141c
Allow empty lines at beginnings of more blocks ( #4130 )
...
Fixes #4043 , fixes #619
These include nested functions and methods.
I think the nested function case quite clearly improves readability. I
think the method case improves consistency, adherence to PEP 8 and
resolves a point of contention.
2024-01-01 15:46:09 -08:00
Jelle Zijlstra
db9c592967
Unify docstring detection ( #4095 )
...
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
2023-12-27 22:59:30 -08:00
cobalt
c80685f361
Treat walruses like other binary operators in subscripts ( #4109 )
...
Fixes #4078
2023-12-27 22:24:25 -08:00
Jelle Zijlstra
ebd543c0ac
Fix feature detection for parenthesized context managers ( #4104 )
2023-12-11 21:37:15 -08:00
Jelle Zijlstra
eb7661f8ab
Fix another case where we format dummy implementation for non-functions/classes ( #4103 )
2023-12-11 14:41:41 -08:00
Jelle Zijlstra
9aea9768cb
Only use dummy implementation logic for functions and classes ( #4066 )
...
Fixes #4063
2023-12-11 13:19:02 -08:00
Jelle Zijlstra
61b529b7d1
Allow empty lines at beginning of blocks (again) ( #4060 )
2023-12-09 18:29:09 -08:00
John Litborn
e4ae213f06
test preview cases with line-length 1 unless explicitly skipped ( #4087 )
...
* Add new flag for tests, --no-preview-line-length-1, to be used for test cases known to not work in preview mode with line-length=1. Also split out the problematic cases in three cases to separate files. Removed now redundant file which explicitly tested preview annotations with line-length=1
* mode.preview -> preview_mode, mark pep_572_remove_parens as failing with ll1
2023-12-06 07:17:33 -08:00
John Litborn
50d5756e8e
fix crash in preview mode with --line-length=1 ( #4086 )
2023-12-05 10:19:24 -08:00
Riyazuddin Khan
3416b2c82d
Fix: --line-ranges dedents a # fmt: off in the middle of a decorator ( #4084 )
...
Fixes #4068
2023-12-04 10:10:03 -08:00
Henri Holopainen
fb5e5d2be6
Prefer more equal signs before a break when splitting chained assignments ( #4010 )
...
Fixes #4007
2023-11-22 19:11:49 -08:00
Yilei Yang
a8062983cd
Disable the stability check with --line-ranges for now. ( #4034 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-20 20:45:39 -08:00
tungol
89e28ea66f
Permit standalone form feed characters at the module level ( #4021 )
...
Co-authored-by: Stephen Morton <git@tungol.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-20 20:44:33 -08:00
Yilei Yang
11da02da72
Handle more huggable immediately nested parens/brackets. ( #4012 )
...
Fixes #4011
2023-11-18 11:47:05 -08:00
Henri Holopainen
1a7d9c2f58
Preserve visible quote types for f-string debug expressions ( #4005 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-07 20:19:32 -08:00
Henri Holopainen
66008fda5d
[563] Fix standalone comments inside complex blocks crashing Black ( #4016 )
...
Bracket depth is not an accurate indicator of standalone comment position inside more complex blocks because bracket depth can be virtual (in loops' and lambdas' parameter blocks) or from optional parens. Here we try to stop cumulating lines upon standalone comments in complex blocks, and try to make standalone comment processing more simple. The fundamental idea is, that if we have a standalone comment, it needs to go on its own line, so we always have to split.
This is not perfect, but at least a first step.
2023-11-07 11:29:24 -08:00
rdrll
50ed6221d9
Fix long case blocks not split into multiple lines ( #4024 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-07 06:31:58 -08:00
Yilei Yang
46be1f8e54
Support formatting specified lines ( #4020 )
2023-11-06 18:05:25 -08:00
Shantanu
ecbd9e8cf7
Fix crash with f-string docstrings ( #4019 )
...
Python does not consider f-strings to be docstrings, so we probably
shouldn't be formatting them as such
Fixes #4018
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-06 16:58:43 -08:00
Yilei Yang
e808e61db8
Preview: Keep requiring two empty lines between module-level docstring and first function or class definition ( #4028 )
...
Fixes #4027 .
2023-11-06 14:30:04 -08:00
Jelle Zijlstra
c54c213d6a
Fix crash on await (a ** b) ( #3994 )
2023-11-02 20:42:11 -07:00
Jelle Zijlstra
5758da6e3c
Fix bytes strings being treated as docstrings ( #4003 )
...
Fixes #4002
2023-10-31 17:11:28 -07:00
Henri Holopainen
e50110353a
Produce equivalent code for docstrings containing backslash followed by whitespace(s) before newline ( #4008 )
...
Fixes #3727
2023-10-31 08:27:11 -07:00