Skip to content
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

INTERNAL ERROR: Black produced code that is not equivalent to the source. #1642

Closed
mithrandi opened this issue Aug 27, 2020 · 5 comments
Closed
Labels
F: strings Related to our handling of strings T: bug Something isn't working

Comments

@mithrandi
Copy link
Contributor

This is happening with three source files, running black --check . over Axiom:

https://github.com/twisted/axiom/blob/35098ebf2f4a799904ac8a65c12969f89c2e1f10/axiom/scripts/axiomatic.py

--- src
+++ dst
@@ -254,11 +254,11 @@
           body=
             Expr(
               value=
                 Constant(
                   value=
-                    b'Turn a byte string from the command line into a unicode string.\n        ',  # bytes
+                    b'Turn a byte string from the command line into a unicode string.',  # bytes
                 )  # /Constant
             )  # /Expr
             Assign(
               targets=
                 Name(

https://github.com/twisted/axiom/blob/35098ebf2f4a799904ac8a65c12969f89c2e1f10/axiom/attributes.py

--- src
+++ dst
@@ -14618,11 +14618,11 @@
       body=
         Expr(
           value=
             Constant(
               value=
-                b'A type constraint was violated.\n    ',  # bytes
+                b'A type constraint was violated.',  # bytes
             )  # /Constant
         )  # /Expr
         FunctionDef(
           args=
             arguments(
@@ -21657,11 +21657,11 @@
       body=
         Expr(
           value=
             Constant(
               value=
-                b"\n    Attribute representing a number with a specified number of decimal\n    places.\n\n    This is stored in SQLite as a binary integer multiplied by M{10**N}\n    where C{N} is the number of decimal places required by Python. \n    Therefore, in-database multiplication, division, or queries which\n    compare to integers or fixedpointdecimals with a different number of\n    decimal places, will not work.  Also, you cannot store, or sum to, fixed\n    point decimals greater than M{(2**63)/(10**N)}.\n\n    While L{ieee754_double} is handy for representing various floating-point\n    numbers, such as scientific measurements, this class (and the associated\n    Python decimal class) is more appropriate for arithmetic on sums of money.\n\n    For more information on Python's U{Decimal\n    class<http://www.python.org/doc/current/lib/module-decimal.html>} and on\n    general U{computerized Decimal math in\n    general<http://www2.hursley.ibm.com/decimal/decarith.html>}.\n\n    This is currently a private helper superclass because we cannot store\n    additional metadata about column types; maybe we should fix that.\n\n    @cvar decimalPlaces: the number of points of decimal precision allowed by\n    the storage and retrieval of this class.  *Points beyond this number\n    will be silently truncated to values passed into the database*, so be\n    sure to select a value appropriate to your application!\n    ",  # bytes
+                b"\n    Attribute representing a number with a specified number of decimal\n    places.\n\n    This is stored in SQLite as a binary integer multiplied by M{10**N}\n    where C{N} is the number of decimal places required by Python.\n    Therefore, in-database multiplication, division, or queries which\n    compare to integers or fixedpointdecimals with a different number of\n    decimal places, will not work.  Also, you cannot store, or sum to, fixed\n    point decimals greater than M{(2**63)/(10**N)}.\n\n    While L{ieee754_double} is handy for representing various floating-point\n    numbers, such as scientific measurements, this class (and the associated\n    Python decimal class) is more appropriate for arithmetic on sums of money.\n\n    For more information on Python's U{Decimal\n    class<http://www.python.org/doc/current/lib/module-decimal.html>} and on\n    general U{computerized Decimal math in\n    general<http://www2.hursley.ibm.com/decimal/decarith.html>}.\n\n    This is currently a private helper superclass because we cannot store\n    additional metadata about column types; maybe we should fix that.\n\n    @cvar decimalPlaces: the number of points of decimal precision allowed by\n    the storage and retrieval of this class.  *Points beyond this number\n    will be silently truncated to values passed into the database*, so be\n    sure to select a value appropriate to your application!\n    ",  # bytes
             )  # /Constant
         )  # /Expr
         FunctionDef(
           args=
             arguments(

https://github.com/twisted/axiom/blob/35098ebf2f4a799904ac8a65c12969f89c2e1f10/axiom/store.py

--- src
+++ dst
@@ -492,11 +492,11 @@
       body=
         Expr(
           value=
             Constant(
               value=
-                b'You must define some attributes on every item.\n    ',  # bytes
+                b'You must define some attributes on every item.',  # bytes
             )  # /Constant
         )  # /Expr
       decorator_list=
       name=
         'NoEmptyItems',  # str
@@ -35928,11 +35928,11 @@
           body=
             Expr(
               value=
                 Constant(
                   value=
-                    b'For use with SELECT (or SELECT-like PRAGMA) statements.\n        ',  # bytes
+                    b'For use with SELECT (or SELECT-like PRAGMA) statements.',  # bytes
                 )  # /Constant
             )  # /Expr
             If(
               body=
                 Assign(

This happens with master (20.8b2.dev6+g7fe19fa) too.

@mithrandi mithrandi added the T: bug Something isn't working label Aug 27, 2020
@myselfhimself
Copy link

myselfhimself commented Aug 27, 2020

Hi
There is a discrepancy of formatting between black 19 (local computer) and black 20 (freshest from CI)

I am trying to downgrade to a now locked version of black to prevent this in my CI, but I cannot remember which version black would accept to install on Mac OS with pip (side-issue..)

@ambv
Copy link
Collaborator

ambv commented Aug 27, 2020

This is #1632 and #1635, but with Black actually catching it as and AST discrepancy. Somehow the other examples don't.

@myselfhimself
Copy link

Hi
There is a discrepancy of formatting between black 19 (local computer) and black 20 (freshest from CI)

I am trying to downgrade to a now locked version of black to prevent this in my CI, but I cannot remember which version black would accept to install on Mac OS with pip (side-issue..)

Now unsure of this. Please ignore my comment for now.

@ichard26
Copy link
Collaborator

@ambv for the case of #1635, PR #1593 allows the removal of trailing space in docstrings so that's why the AST checks don't catch it.

@JelleZijlstra
Copy link
Collaborator

This no longer crashes on current main.

@ichard26 ichard26 added the F: strings Related to our handling of strings label May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: strings Related to our handling of strings T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants