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
269190274b
Clean up dead code in magic trailing comma logic ( #4131 )
2024-01-01 17:29:21 -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
Shantanu
bf6cabc804
Do not round cache mtimes ( #4128 )
...
Fixes #4116
This logic was introduced in #3821 , I believe as a result of copying
logic inside mypy that I think isn't relevant to Black
2023-12-27 22:24:57 -08:00
cobalt
c80685f361
Treat walruses like other binary operators in subscripts ( #4109 )
...
Fixes #4078
2023-12-27 22:24:25 -08:00
Anupya Pamidimukkala
51786141cc
Fix nits, chain comparisons, unused params, hyphens ( #4114 )
2023-12-27 22:23:42 -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
ce28be2705
Add dedicated preview feature for East Asian Width ( #4097 )
2023-12-09 21:14:25 -08:00
Jelle Zijlstra
61b529b7d1
Allow empty lines at beginning of blocks (again) ( #4060 )
2023-12-09 18:29:09 -08:00
cobalt
432d9050c3
docs: Unify option descriptions between --help
and the_basics.md
( #4076 )
2023-12-07 09:32:06 -08:00
cobalt
50e287cece
docs: Clarify include/exclude documentation ( #4072 )
2023-12-07 08:38:57 -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
exag
66ec056e39
Fix minor typos in docstrings ( #4085 )
2023-12-03 21:47:30 -08:00
Alex Waygood
69d49c5a6f
Bump mypy to 1.7.1 ( #4069 )
2023-11-24 06:19:54 -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
Alex Waygood
d93a942a79
Upgrade mypy to 1.6.1 ( #4049 )
2023-11-18 11:42:36 -08:00
Alex Waygood
c4cd200a06
Make flake8 pass when run with Python 3.12 ( #4050 )
2023-11-18 11:41:46 -08:00
Alex Waygood
1b6b0bfcac
Improve annotations for black.concurrency.cancel
( #4047 )
2023-11-17 07:57:00 -08:00
Ran Benita
72e7a2e43e
Remove redundant condition from has_magic_trailing_comma
( #4023 )
...
The second `if` cannot be true at its execution point, because it is
already covered by the first `if`. The condition
`comma.parent.type == syms.subscriptlist` always holds if
`closing.parent.type == syms.trailer` holds, because `subscriptlist`
only appears inside `trailer` in the grammar:
```
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
subscriptlist: (subscript|star_expr) (',' (subscript|star_expr))* [',']
```
2023-11-07 20:21:33 -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
Shantanu
2e4fac9d87
Apply force exclude logic before symlink resolution ( #4015 )
2023-11-07 11:31:44 -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
Shantanu
e2f2bd076f
Minor refactoring in get_sources and gen_python_files ( #4013 )
2023-11-01 06:20:14 -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
Henri Holopainen
ddfecf06c1
Hug parens also with multiline unpacking ( #3992 )
2023-10-30 08:35:26 -07:00
sth
c369e446f9
Fix matching of absolute paths in --include
( #3976 )
2023-10-27 00:43:51 -07:00
Henri Holopainen
878937bcc3
[2213] Add support for single line format skip with other comments on the same line ( #3959 )
2023-10-25 09:47:21 -07:00
Henri Holopainen
1d4c31aa58
[925] Improve multiline dictionary and list indentation for sole function parameter ( #3964 )
2023-10-25 08:35:37 -07:00
Henri Holopainen
2db5ab0a7b
Allow empty line after block open before a comment or compound statement ( #3967 )
2023-10-23 07:38:36 -07:00
Henri Holopainen
882d8795c6
Fix merging implicit multiline strings that have inline comments ( #3956 )
...
* Fix test behaviour
* Add new test cases
* Skip merging strings that have inline comments
* Don't merge lines with multiline strings with inline comments
* Changelog entry
* Document implicit multiline string merging rules
* Fix PR number
2023-10-19 20:09:33 -07:00
Jelle Zijlstra
bb588073ab
Fix parser bug where "type" was misinterpreted as a keyword inside a match ( #3950 )
...
Fixes #3790
Slightly hacky, but I think this is correct and it should also improve performance somewhat.
2023-10-17 00:59:15 -07:00
Jelle Zijlstra
722735d20e
Fix grammar for type alias support ( #3949 )
...
Fixes #3948
2023-10-16 10:53:38 -07:00
Jelle Zijlstra
abe57e3d92
Treat raw strings like other docstrings ( #3947 )
...
Fixes #3944
2023-10-16 10:51:51 -07:00
Henri Holopainen
1648ac5180
Fix long lines with power operator(s) getting splitted before line length ( #3942 )
...
Fixes #3889
2023-10-16 07:08:21 -07:00