]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

fix misformatting of floats with leading zeros (#464)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Mon, 20 Aug 2018 15:19:25 +0000 (08:19 -0700)
committerGitHub <noreply@github.com>
Mon, 20 Aug 2018 15:19:25 +0000 (08:19 -0700)
black.py
tests/data/numeric_literals.py

index b65693e91d0cac0b5087b32397f22c64cee1b5e0..5550b23102025e4e11dc1a4bfe4fda2b7a1c3d83 100644 (file)
--- a/black.py
+++ b/black.py
@@ -2564,7 +2564,9 @@ def format_int_string(text: str, allow_underscores: bool) -> str:
         # No underscores for numbers <= 6 digits long.
         return text
 
-    return format(int(text), "3_")
+    # Avoid removing leading zeros, which are important if we're formatting
+    # part of a number like "0.001".
+    return format(int("1" + text), "3_")[1:].lstrip("_")
 
 
 def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None:
index 8999b9d403830f3baa7e641a420f35663ae07ad5..2dc64c75c8b7c07ccb9d5aadb215023af6f2c7b8 100644 (file)
@@ -14,6 +14,7 @@ x = 123456789.123456789J
 x = 0XB1ACC
 x = 0B1011
 x = 0O777
+x = 0.000000006
 
 # output
 
@@ -34,3 +35,4 @@ x = 123_456_789.123_456_789j
 x = 0xb1acc
 x = 0b1011
 x = 0o777
+x = 0.000_000_006