Commit Graph

95 Commits

Author SHA1 Message Date
Joe Antonakakis
154b98579d Fix async blackd tests which won't fail currently (#966) 2019-08-05 10:06:12 +01:00
Joe Antonakakis
c7495b9aa0 Fix unstable format involving backslash + whitespace at beginning of file (#948) 2019-08-04 10:03:19 +01:00
Zsolt Dollenstein
e66451761f appease flake8... 2019-07-28 16:40:04 +01:00
Zsolt Dollenstein
6b5eb7d465 skip tests touching aiohttp when known exception occurs 2019-07-28 16:35:10 +01:00
Zsolt Dollenstein
2848e2e1d6
Support PEP-570 (positional only arguments) (#946)
Code using positional only arguments is considered >= 3.8
2019-07-28 16:17:33 +01:00
Zsolt Dollenstein
d8fa8df052
Add support for walrus operator (#935)
* Parse `:=` properly
* never unwrap parenthesis around `:=`
* When checking for AST-equivalence, use `ast` instead of `typed-ast` when running on python >=3.8
* Assume code that uses `:=` is at least 3.8
2019-07-28 16:03:23 +01:00
dylanjblack
9394de150e Fix trailing comma for function with one arg (#880) (#891)
Modified maybe_remove_trailing_comma to remove trailing commas for
typedarglists (in addition to arglists), and updated line split logic
to ensure that all lines in a function definition that contain only one
arg have a trailing comma.
2019-06-14 21:49:49 -07:00
Jelle Zijlstra
957ba24bb6
remove obviously unnecessary parentheses (#850)
Fixes #548
2019-05-15 21:11:04 -07:00
Benjamin Woodruff
f8617f975d
Add support for always tokenizing async/await as keywords
Fixes #593

I looked into this bug with @ambv and @carljm, and we reached the
conclusion was that it's not possible for the tokenizer to determine if
async/await is a keyword inside all possible generators without breaking
the grammar for older versions of Python.

Instead, we introduce a new tokenizer mode for Python 3.7+ that will
cause all async/await instances to get parsed as a reserved keyword,
which should fix async/await inside generators.
2019-05-09 17:59:29 +02:00
Jason Fried
866be06646 Make --safe work for Python2.7 syntax, by using typed_ast for safe validation (#840) 2019-05-08 07:45:59 -07:00
Carl Meyer
6fdbdb4ee3
Avoid unstable formatting when comment follows escaped newline. (#839). Fixes #767. 2019-05-08 09:53:20 -04:00
Jelle Zijlstra
de806405d2 Add parentheses around tuple unpack assignment (#832)
Fixes #656
2019-05-07 09:51:28 -04:00
Jelle Zijlstra
6b994fdb8a
fix handling of comments in from imports (#829)
Fixes #671
2019-05-06 09:13:25 -04:00
Jelle Zijlstra
cea13f4984
Split the TRAILING_COMMA feature (#763) 2019-03-25 08:22:02 -07:00
Jelle Zijlstra
ba64fc757c
redo grammar selection, add test (#765) 2019-03-16 11:35:18 -07:00
Andy Freeland
d6db1c12a8 Fix print() function on Python 2 (#754)
Fixes #752
2019-03-14 16:42:54 -07:00
Łukasz Langa
6af55d8851
Mention tab comment fixes, extend tests 2019-03-14 17:17:50 +01:00
Anders-Petter Ljungquist
227c2d77b4 Changes default logger used by blib2to3 Driver (#732)
... to stop it from spamming the log when black is used as a library in another
    python application.

When used indirectly by black the logger initiated in `driver.py` will emit
thousands of debug messages making the debug level of the root logger virtually
useless. By getting a named logger instead the verbosity of logging from this
module can easily be controlled by setting its log level.

Fixes #715
2019-03-14 13:39:42 +01:00
Jelle Zijlstra
ea55ff2878
remove Python implementation-specific versions (#736) 2019-03-07 16:34:34 -08:00
Jelle Zijlstra
21ab37a5d9
remove --py36 (#724)
Fixes #703.
2019-02-24 09:15:03 -08:00
Zsolt Dollenstein
250ba7f04b Remove numeric underscore normalization (#696) 2019-02-06 19:16:49 -08:00
Jelle Zijlstra
36d3c516d3
Add --target-version option to allow users to choose targeted Python versions (#618) 2019-02-06 18:43:50 -08:00
Samuel Cormier-Iijima
66aa676278 Fix indent calculation with tabs when computing prefixes (#595)
Closes #262
2019-02-04 18:55:01 -08:00
Jan Hnátek
f6643c4f0c Fix location of expression.diff in the change notification message (#670) 2019-02-04 18:42:42 -08:00
Utsav Shah
024c9cab55 Add support for special comments in multiline functions (#642) 2019-01-05 11:20:12 -08:00
Jim Brännlund
4809e365d4 Silence expected stderr (#621)
* Silence expected stderr output during test

* Change based on PR comment
2018-11-29 21:43:22 +00:00
Jelle Zijlstra
8d58827376
Refactor Travis (#614)
Fixes #305 

- Run separate jobs for mypy, self-formatting, flake8, and test runs.
- Don't run flake8 in 3.8 because it is broken (and we can't really expect flake8 to always keep up with 3.8 development).
- Fix unused variable in test
2018-11-20 08:42:43 -08:00
Zsolt Dollenstein
5f9eb9e4f7 Add underscores to numeric literals with more than six digits (#529) 2018-09-26 12:32:11 +01:00
Zsolt Dollenstein
a82f186787 blackd: a HTTP server for blackening (#460) 2018-09-17 10:02:25 -07:00
Zsolt Dollenstein
66a6be642c fix lint errors 2018-08-26 21:27:33 +01:00
Zsolt Dollenstein
401836d02e add test case for preserving newlines from stdin 2018-08-26 21:19:22 +01:00
Jelle Zijlstra
b53cb94743 fix bracket match bug (#470)
* fix bracket match bug

* add missing test file
2018-08-23 12:52:07 +01:00
Zsolt Dollenstein
883689366c Support parsing of async generators in non-async functions (#165)
This is a new syntax added in python3.7, so black can't verify that reformatting will not change the ast unless black itself is run with 3.7. We'll need to change the error message black gives in this case. @ambv any ideas?

Fixes #125.
2018-08-20 14:47:58 +01:00
Jelle Zijlstra
b719d85ccc
autodetect Python 3.6 on the basis of underscores (#461) 2018-08-19 21:02:06 -07:00
Jelle Zijlstra
cc48bc56ca normalize numeric literals (#454)
Fixes #452

I ended up making a couple of other normalizations to numeric literals
too (lowercase everything, don't allow leading or trailing . in floats,
remove redundant + sign in exponent). I don't care too much about those,
so I'm happy to change the behavior there.

For reference, here is Python's grammar for numeric literals:
https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals
2018-08-17 15:03:58 +01:00
Zsolt Dollenstein
df965b0558 update to mypy 0.620 and make tests pass again
Fixes #408
2018-07-18 22:10:52 +01:00
Zsolt Dollenstein
dd8bde6d2f Improve get_future_imports implementation.
Closes #389.
2018-07-02 17:49:47 +01:00
Łukasz Langa
048efa7476 Trivial nits 2018-06-19 23:08:10 -07:00
Łukasz Langa
2dfa69bb7f Stop Click from crashing Black on invalid environments
Fixes #277
2018-06-19 22:55:57 -07:00
Łukasz Langa
df2ae3bbe6 Use the separate pass for # fmt: off on all code
This removes the hacky exception-based handling that didn't work across
statement boundaries.

Fixes #335
2018-06-19 17:32:41 -07:00
Neraste
42a3fe5331 Ignore symbolic links pointing outside of the root directory (#339)
Fixes #338
2018-06-13 00:07:04 -07:00
Łukasz Langa
ec31ee967d Make test_black.py work in profilers 2018-06-09 18:49:39 -07:00
Łukasz Langa
489d00ed8f Support pyproject.toml
Fixes #65
2018-06-06 17:02:10 -07:00
Łukasz Langa
f71db23824 Move test data to data 2018-06-06 15:48:38 -07:00
Zsolt Dollenstein
33baccd88e Change tests with stdin/out to exercise black.main (#307) 2018-06-06 15:42:50 -07:00
Łukasz Langa
7fc6ce9906 Fix handling of empty files 2018-06-04 19:04:29 -07:00
Łukasz Langa
728e5a2f1e Properly format unified diff
Previously we weren't using timestamps.
2018-06-04 18:07:03 -07:00
Łukasz Langa
ed91dd4de6 Make source handling use sets instead of lists
Also, sort cached file output to be (more) deterministic.
2018-06-04 15:53:37 -07:00
Zsolt Dollenstein
00a302560b Preserve line endings when formatting a file in place (#288) 2018-06-04 15:52:06 -07:00
Łukasz Langa
4c352ad4be Add --verbose and report excluded paths in it, too
Fixes #283
2018-06-04 12:09:18 -07:00