@@ -1529,6 +1529,13 @@ def get_imports_from_children(children: List[LN]) -> Generator[str, None, None]:
1529
1529
return imports
1530
1530
1531
1531
1532
+ def _black_info () -> str :
1533
+ return (
1534
+ f"Black { __version__ } on "
1535
+ f"Python ({ platform .python_implementation ()} ) { platform .python_version ()} "
1536
+ )
1537
+
1538
+
1532
1539
def assert_equivalent (src : str , dst : str ) -> None :
1533
1540
"""Raise AssertionError if `src` and `dst` aren't equivalent."""
1534
1541
try :
@@ -1546,7 +1553,7 @@ def assert_equivalent(src: str, dst: str) -> None:
1546
1553
except Exception as exc :
1547
1554
log = dump_to_file ("" .join (traceback .format_tb (exc .__traceback__ )), dst )
1548
1555
raise ASTSafetyError (
1549
- f"INTERNAL ERROR: Black produced invalid code: { exc } . "
1556
+ f"INTERNAL ERROR: { _black_info () } produced invalid code: { exc } . "
1550
1557
"Please report a bug on https://github.com/psf/black/issues. "
1551
1558
f"This invalid output might be helpful: { log } "
1552
1559
) from None
@@ -1556,9 +1563,9 @@ def assert_equivalent(src: str, dst: str) -> None:
1556
1563
if src_ast_str != dst_ast_str :
1557
1564
log = dump_to_file (diff (src_ast_str , dst_ast_str , "src" , "dst" ))
1558
1565
raise ASTSafetyError (
1559
- "INTERNAL ERROR: Black produced code that is not equivalent to the "
1560
- " source. Please report a bug on "
1561
- f"https://github.com/psf/black/issues. This diff might be helpful: { log } "
1566
+ f "INTERNAL ERROR: { _black_info () } produced code that is not equivalent to"
1567
+ " the source. Please report a bug on https://github.com/psf/black/issues. "
1568
+ f" This diff might be helpful: { log } "
1562
1569
) from None
1563
1570
1564
1571
@@ -1584,9 +1591,9 @@ def assert_stable(
1584
1591
diff (dst , newdst , "first pass" , "second pass" ),
1585
1592
)
1586
1593
raise AssertionError (
1587
- "INTERNAL ERROR: Black produced different code on the second pass of the "
1588
- " formatter. Please report a bug on https://github.com/psf/black/issues. "
1589
- f" This diff might be helpful: { log } "
1594
+ f "INTERNAL ERROR: { _black_info () } produced different code on the second"
1595
+ " pass of the formatter. Please report a bug on"
1596
+ f" https://github.com/psf/black/issues. This diff might be helpful: { log } "
1590
1597
) from None
1591
1598
1592
1599
0 commit comments