Comments (8)
Kenneth's right. The README states you should be able to reformat even well-behaved Python 2.7 code. This is simply an omission on my part because I don't run Python 2.7 on my own projects anymore.
But, the **kwargs trailing comma is such a small thing to fix that will unlock compatibility with 2.7-3.5 that I'm going to do it for sure.
from black.
I don't think this is an issue. The docs clearly state python3.6+ compatibility.
from black.
No, the tool is to be run on Python 3.6, but is to produce code compatible with even Python 2.
from black.
Watch out that this also affects
def foo(*args,): # error on 3.5 and earlier
...
def foo(a, *, b,): # error on 3.5 and earlier
...
(For reference it's bpo-9232.)
from black.
Yes, I'm familiar with the additional forms. Essentially, whenever the argument list includes a star, it's no longer safe to use a trailing comma unless such trailing comma or an f-string was already present in the file (which signifies the code is already 3.6+).
from black.
from black.
Yes, that's the flip side. An easy way to spot those for you would be to run:
$ python3.5 -m compileall .
in your directory and see where you have failures. Hopefully there's not going to be too many. Let me know, if so I'll add a temporary option to never add trailing commas so you can fix your early adopter misformattings :-)
from black.
This is now fixed as described above. @kennethreitz, let me know if you need help with unbreaking the 3.6-only formattings in your code. If those are pushed to GitHub, I will happily make a pull request that undoes the damage.
from black.
Related Issues (20)
- Changes to files happing quickly after running `black` are not detected HOT 4
- `blank_line_after_nested_stub_class`: blank line got added after a nested class with `...` HOT 1
- Black 23.12.0 requires aiohttp when the d extra isn't installed HOT 3
- `allow_empty_first_line_before_new_block_or_comment` can lead to inconsistent formatting HOT 2
- Unable to install dependency aiohttp using requirements.txt generated by poetry after upgrade to black 23.12.0 HOT 2
- Preview style feedback: Parenthesizing long dict, conditional, and type annotations HOT 6
- Black fails to format complicated f-string HOT 2
- What can I / should I expect when working with huge files (100 MB+)? HOT 1
- `wrap_long_dict_value_in_parens` can introduce unnecessary nesting for dicts in dicts
- Installation and update of black over a docker container HOT 1
- f-string with internal same-quote expression HOT 1
- Error on invalid configuration HOT 6
- Method argument values as multi-line strings and continuation visual indents HOT 1
- Whitespace before `fmt: skip` comment is normalised HOT 8
- Add option for single quoted strings as default HOT 2
- Possible to format a Python code contained in a string variable? HOT 1
- Formatting of long lines only work when line-length is specified HOT 2
- Inconsistent formatting of `**` in tenary expression. HOT 2
- Can not format `method` code when method str parameter length default value too long HOT 5
- INTERNAL ERROR: Black produced invalid code: f-string: expecting '}' HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from black.