-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot format file (black produced different code on the second pass of the formatter) #1770
Comments
Here's a smaller repro with latest def test_stability():
assert jobs.get_jobs(["css/build-css-testsuite.sh",
"css/CSS21/test-001.html"],
includes=["stability"]) == {"stability"} Log: Mode(target_versions={<TargetVersion.PY38: 8>, <TargetVersion.PY37: 7>, <TargetVersion.PY36: 6>}, line_length=88, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -1,4 +1,5 @@
def test_stability():
- assert jobs.get_jobs(["css/build-css-testsuite.sh",
- "css/CSS21/test-001.html"],
- includes=["stability"]) == {"stability"}
+ assert jobs.get_jobs(
+ ["css/build-css-testsuite.sh", "css/CSS21/test-001.html"],
+ includes=["stability"],
+ ) == {"stability"}
--- first pass
+++ second pass
@@ -1,5 +1,8 @@
def test_stability():
- assert jobs.get_jobs(
- ["css/build-css-testsuite.sh", "css/CSS21/test-001.html"],
- includes=["stability"],
- ) == {"stability"}
+ assert (
+ jobs.get_jobs(
+ ["css/build-css-testsuite.sh", "css/CSS21/test-001.html"],
+ includes=["stability"],
+ )
+ == {"stability"}
+ ) |
This is caused by the changes in 586d242 (cc @ambv) Amusingly the commit message calls out this exact problem as a pain point:
|
I have what seems like a similar failure case. Occurs with Apologies if it's not useful, but just in case it is: def test_do_a_thing():
assert "belongs_to" in do_a_thing({
"series": {"unitId": 4},
"data": ["2001-01-01", "2001-12-31"]
}, add_belongs_to=True)[0] Gives the error: Mode(target_versions=set(), line_length=88, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -1,5 +1,8 @@
def test_do_a_thing():
- assert "belongs_to" in do_a_thing({
- "series": {"unitId": 4},
- "data": ["2001-01-01", "2001-12-31"]
- }, add_belongs_to=True)[0]
+ assert (
+ "belongs_to"
+ in do_a_thing(
+ {"series": {"unitId": 4}, "data": ["2001-01-01", "2001-12-31"]},
+ add_belongs_to=True,
+ )[0]
+ )
--- first pass
+++ second pass
@@ -1,8 +1,5 @@
def test_do_a_thing():
- assert (
- "belongs_to"
- in do_a_thing(
- {"series": {"unitId": 4}, "data": ["2001-01-01", "2001-12-31"]},
- add_belongs_to=True,
- )[0]
- )
+ assert "belongs_to" in do_a_thing(
+ {"series": {"unitId": 4}, "data": ["2001-01-01", "2001-12-31"]},
+ add_belongs_to=True,
+ )[0] This one seems pretty sensitive. Black will succeed if different parts of this example are changed: removing the final |
I appeared the same problem, which version can work now? |
Black version |
Black version |
Hello! All reproduction cases in this issue format without error on master. The fixing commit was 8672af3 from PR GH-2126. I'll be marking this issue as a duplicate of GH-1629 since that's what GH-2126 aimed to fix and it's highly likely this issue falls under GH-1629. Since we use the issue tracker as a reflection of what's on master, I'll be closing this issue. If you have any issues, especially with the new (but stable) output, please open a new issue. Oh and the fix should be available in a published release soon, see GH-2125 for more info. Thank you for reporting! |
I'm unable to format some files with
black
version 20.8b1.Steps to reproduce:
Use https://hg.mozilla.org/mozilla-central/raw-file/d4e1e62aed03db1d447f6b31b8d1347c2ad2e43b/testing/web-platform/tests/tools/ci/tests/test_jobs.py (we have other examples of similarly failing Python files in-tree, but this is the shortest example I was able to find)
Run
black test_jobs.py
See error:
Expected behavior: No failure to reformat.
Environment:
This bug also occurs on master (tested on https://black.now.sh/?version=master)
The text was updated successfully, but these errors were encountered: