Skip to content

Conversation

@tammoippen
Copy link
Owner

No description provided.


def int_formatter(val, chars, delta, left):
return '{:{}{}}'.format(int(val), '<' if left else '>', chars)
return "{:{}{}}".format(int(val), "<" if left else ">", chars)

Check warning

Code scanning / CodeQL

Unused argument in a formatting call Warning

Too many arguments for string format. Format
"{:{}{}"
requires only 2, but 3 are provided.

Copilot Autofix

AI about 2 months ago

In general, to fix “unused argument in a formatting call” you either remove the surplus argument or adjust the format string so that every argument is actually referenced by a placeholder. Here the function int_formatter(val, chars, delta, left) is clearly intended to format val as an integer with left or right alignment and a width of chars. The current format string "{:{}{}}" has only two fields: the first is the value to format, and the second fills the entire format spec; chars is never referenced, making it unused and breaking the intended behavior.

The best fix without changing external behavior is to update the format string on line 54 so that it uses both the alignment character and the width. This is done by including a second nested replacement field for chars in the format specification: "{:{}{}{}}".format(int(val), "<" if left else ">", chars). Here:

  • Outer {}: formatted value (int(val)).
  • Inner {}{} inside the format spec: first {} is the alignment ("<" or ">"), second {} is the width (chars).

No imports or other definitions are required; we only update the single return statement in int_formatter in examples/logo_example.py.

Suggested changeset 1
examples/logo_example.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/examples/logo_example.py b/examples/logo_example.py
--- a/examples/logo_example.py
+++ b/examples/logo_example.py
@@ -51,7 +51,7 @@
 
 
 def int_formatter(val, chars, delta, left):
-    return "{:{}{}}".format(int(val), "<" if left else ">", chars)
+    return "{:{}{}{}}".format(int(val), "<" if left else ">", chars)
 
 
 def logo():
EOF
@@ -51,7 +51,7 @@


def int_formatter(val, chars, delta, left):
return "{:{}{}}".format(int(val), "<" if left else ">", chars)
return "{:{}{}{}}".format(int(val), "<" if left else ">", chars)


def logo():
Copilot is powered by AI and may make mistakes. Always verify output.
def __init__(self):
self.formatters = OrderedDict()
class Formatter(Protocol):
def __call__(self, val: Any, chars: int, delta: Any, left: bool) -> str: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.

Copilot Autofix

AI about 2 months ago

In general, to fix a “statement has no effect” issue where an ellipsis (...) is used as a standalone expression, replace it with an appropriate construct that clearly expresses the intent: usually pass for “do nothing”, or raising NotImplementedError if the method must not be called directly.

Here, Formatter is a Protocol specifying the call signature; its __call__ body is never meant to run and is only present to satisfy the type checker. The minimal, behavior-preserving fix is to replace the ellipsis expression with pass inside the method body. This keeps the method abstract in practice (since Protocol methods aren’t normally invoked on the protocol itself), but removes the no-op expression and the warning. No new imports, methods, or other definitions are required.

Concretely: in plotille/_input_formatter.py, at the definition of class Formatter(Protocol):, change the body of __call__ from ... to pass on line 42 (keeping the signature unchanged).

Suggested changeset 1
plotille/_input_formatter.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/plotille/_input_formatter.py b/plotille/_input_formatter.py
--- a/plotille/_input_formatter.py
+++ b/plotille/_input_formatter.py
@@ -39,7 +39,8 @@
 
 
 class Formatter(Protocol):
-    def __call__(self, val: Any, chars: int, delta: Any, left: bool) -> str: ...
+    def __call__(self, val: Any, chars: int, delta: Any, left: bool) -> str:
+        pass
 
 
 Converter = Callable[[Any], int | float | datetime]
EOF
@@ -39,7 +39,8 @@


class Formatter(Protocol):
def __call__(self, val: Any, chars: int, delta: Any, left: bool) -> str: ...
def __call__(self, val: Any, chars: int, delta: Any, left: bool) -> str:
pass


Converter = Callable[[Any], int | float | datetime]
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +139 to +141
def _num_formatter(
val: int | float, chars: int, delta: int | float, left: bool = False
) -> str:

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error, as implicit returns always return None.

Copilot Autofix

AI about 2 months ago

In general, to fix mixed implicit/explicit returns you add an explicit return (or raise) on all paths so the function never silently falls through. For _num_formatter, the function’s contract is to return a str for valid numeric inputs or raise an error otherwise. The cleanest fix that preserves behavior is to replace the “unreachable” fall-through with an explicit TypeError for any value that passes the first isinstance but is neither int nor float according to the later checks. This keeps the semantics consistent: unsupported values trigger an exception instead of returning None.

Concretely, in plotille/_input_formatter.py around lines 162–167, we keep the existing return statements for int and float, but replace the # unreachable comment and the implicit fall-through with a raise TypeError(...) that clearly indicates an unsupported numeric type. No new imports are needed; TypeError is built in. All other lines in the snippet remain unchanged.

Suggested changeset 1
plotille/_input_formatter.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/plotille/_input_formatter.py b/plotille/_input_formatter.py
--- a/plotille/_input_formatter.py
+++ b/plotille/_input_formatter.py
@@ -163,7 +163,10 @@
         return _int_formatter(val, chars, left)
     elif isinstance(val, float):
         return _float_formatter(val, chars, left)
-    # unreachable
+    raise TypeError(
+        "Only accepting numeric (int/long/float) "
+        f'types, not "{val}" of type: {type(val)}'
+    )
 
 
 def _float_formatter(val: float, chars: int, left: bool = False) -> str:
EOF
@@ -163,7 +163,10 @@
return _int_formatter(val, chars, left)
elif isinstance(val, float):
return _float_formatter(val, chars, left)
# unreachable
raise TypeError(
"Only accepting numeric (int/long/float) "
f'types, not "{val}" of type: {type(val)}'
)


def _float_formatter(val: float, chars: int, left: bool = False) -> str:
Copilot is powered by AI and may make mistakes. Always verify output.
only store float and metadata internally
@tammoippen tammoippen changed the title Add build system information Type information and datetime improvements Jan 19, 2026
@tammoippen tammoippen merged commit 2660f5d into master Jan 19, 2026
18 checks passed
@tammoippen tammoippen deleted the add-build-system branch January 19, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant