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
0c9899956d
Fix path in test message ( #4102 )
2023-12-11 14:29:33 -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
Alex Waygood
d93a942a79
Upgrade mypy to 1.6.1 ( #4049 )
2023-11-18 11:42:36 -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
Jelle Zijlstra
5edd99312a
Regression test for match variable inside match ( #3993 )
2023-10-28 11:05:53 -07:00
Shantanu
c712d57ca9
Add trailing comma test case for hugging parens ( #3991 )
2023-10-27 12:17:54 -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
Charles Patel
6f84f65285
Migrate mypy config to pyproject.toml ( #3936 )
...
Co-authored-by: Charles Patel <charles.patel@apkudo.com>
2023-10-16 05:24:16 -07:00
Jelle Zijlstra
935f303a0a
Fix test that was not being run ( #3939 )
2023-10-09 20:02:27 -07:00
Daniël van Noord
b7717c3f1e
Standardise newlines after module-level docstrings ( #3932 )
...
Co-authored-by: jpy-git <josephyoung.jpy@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-09 19:34:26 -07:00
Shantanu
5d5bf6e087
Fix cache versioning when BLACK_CACHE_DIR is set ( #3937 )
2023-10-09 18:44:36 -07:00
Jelle Zijlstra
a69bda3b9b
Use inline flags for test cases ( #3931 )
...
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-10-09 18:43:47 -07:00
Shantanu
715f60c11b
Drop support for parsing Python 2 ( #3933 )
2023-10-09 07:02:49 -07:00
John Litborn
36078bc83f
respect magic trailing commas in return types ( #3916 )
2023-10-04 16:42:35 -07:00
Eddie Darling
a91eb73064
Fix comments getting removed from inside parenthesized strings ( #3909 )
...
Since the id of the old leaf may be
the key to comments, the new leaf
must adopt the old comments
2023-10-01 15:35:42 -07:00
John Litborn
9b82120ddb
add support for printing the diff of AST trees when running tests ( #3902 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-28 07:03:24 -07:00
John Litborn
8c5d96ffd3
fix indentation of line breaks in long type hints by adding parens ( #3899 )
...
* fix indentation of line breaks in long type hints by adding parentheses, and remove unnecessary parentheses
* add entry in CHANGES.md, make the style change only in preview mode
2023-09-22 08:38:51 -07:00
Jelle Zijlstra
f7917453c9
Re-export black.Mode ( #3875 )
2023-09-10 16:12:20 -07:00
Shantanu
4eebfd1a7a
Add mypyc test marks to new tests that patch ( #3871 )
...
This is enough for me to get a clean test run on Python 3.9 with mypyc.
I have not been able to repro the pickle failures on either Linux or
macOS.
2023-09-10 07:53:27 -07:00