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:
return f"{before}e{sign}{after}"
return f"{before}e{sign}{after}"
-def format_long_or_complex_number(text: str) -> str:
- """Formats a long or complex string like `10L` or `10j`"""
+def format_complex_number(text: str) -> str:
+ """Formats a complex string like `10j`"""
number = text[:-1]
suffix = text[-1]
number = text[:-1]
suffix = text[-1]
- # Capitalize in "2L" because "l" looks too similar to "1".
- if suffix == "l":
- suffix = "L"
return f"{format_float_or_int_string(number)}{suffix}"
return f"{format_float_or_int_string(number)}{suffix}"
def normalize_numeric_literal(leaf: Leaf) -> None:
"""Normalizes numeric (float, int, and complex) literals.
def normalize_numeric_literal(leaf: Leaf) -> None:
"""Normalizes numeric (float, int, and complex) literals.
- All letters used in the representation are normalized to lowercase (except
- in Python 2 long literals).
- """
+ All letters used in the representation are normalized to lowercase."""
text = leaf.value.lower()
if text.startswith(("0o", "0b")):
# Leave octal and binary literals alone.
text = leaf.value.lower()
if text.startswith(("0o", "0b")):
# Leave octal and binary literals alone.
text = format_hex(text)
elif "e" in text:
text = format_scientific_notation(text)
text = format_hex(text)
elif "e" in text:
text = format_scientific_notation(text)
- elif text.endswith(("j", "l")):
- text = format_long_or_complex_number(text)
+ elif text.endswith("j"):
+ text = format_complex_number(text)
else:
text = format_float_or_int_string(text)
leaf.value = text
else:
text = format_float_or_int_string(text)
leaf.value = text