You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An error occurs while trying to make the error message. It causes the misleading message "TypeError: sequence item 0: expected str instance, FmtStr found".
This can be fixed by changing this statement (formatstringarray.py, around line 175):
msg = "You are trying to fit this value {} into the region {}: {}".format(
fmtstr("".join(value), bg="cyan"),
fmtstr("").join(grid_value),
"\n ".join(grid_fsarray[x] for x in range(len(self.rows))),
)
to make the "\n " a format string:
msg = "You are trying to fit this value {} into the region {}: {}".format(
fmtstr("".join(value), bg="cyan"),
fmtstr("").join(grid_value),
fmtstr("\n ").join(grid_fsarray[x] for x in range(len(self.rows))),
)
This allows the error message not to crash, though it still scrolls off the screen.
ValueError: Error you are trying to replace a region of 11 rows by 15
columns for and area of 165 with a value of len 165. The value
used to replace the region must equal the area of the region
replace.
The error message has some relevance, but still scrolls off the screen and has typos. It would be better to replace that whole section with:
if area < 60 and val_len < 60:
msg = "You are trying to fit this value {} into the region {}: {}".format(
fmtstr("".join(value), bg="cyan"),
fmtstr("").join(grid_value),
fmtstr("\n ").join(grid_fsarray[x] for x in range(len(self.rows))),
)
else:
msg = ""
raise ValueError(
"""{}
Error you are trying to replace a region of {} rows by {}
columns and area of {} with a region of {} rows and total
area of {}. The value used to replace the region must equal the
area of the region replaced.
""".format(
msg,
rowslice.stop - rowslice.start,
colslice.stop - colslice.start,
area,
len(value),
val_len,
)
)
In my example, I am trying to clear a block with spaces but passed rows and columns incorrectly:
def clear(self, left, right, top, bottom):
line = ' ' * max(0, right - left)
block = [line for _ in range(max(0, bottom - top))]
print(f"clear {left=} {right=} {top=} {bottom=}\n{len(line)=} {len(block)=}")
sleep(3)
self.a[left:right, top:bottom] = [line for _ in range(max(0, bottom - top))]
before changes, I get the TypeError. After the immediate fix, I get output of:
clear left=8 right=19 top=5 bottom=20
len(line)=11 len(block)=15
(pause, scroll past bottom)
ValueError: Error you are trying to replace a region of 11 rows by 15
columns for and area of 165 with a value of len 165. The value
used to replace the region must equal the area of the region
replace.
You are trying to fit this value
(full width cyan lines continue from the text a few lines, but with "into the region" in the middle
of the lines. Below the lines is a block with cyan lines).
after the full fix I get:
ValueError:
Error you are trying to replace a region of 11 rows by 15
columns and area of 165 with a region of 15 rows and total
area of 165. The value used to replace the region must equal the
area of the region replaced.
The text was updated successfully, but these errors were encountered:
An error occurs while trying to make the error message. It causes the misleading message "TypeError: sequence item 0: expected str instance, FmtStr found".
This can be fixed by changing this statement (formatstringarray.py, around line 175):
to make the "\n " a format string:
This allows the error message not to crash, though it still scrolls off the screen.
The error message has some relevance, but still scrolls off the screen and has typos. It would be better to replace that whole section with:
In my example, I am trying to clear a block with spaces but passed rows and columns incorrectly:
before changes, I get the TypeError. After the immediate fix, I get output of:
after the full fix I get:
The text was updated successfully, but these errors were encountered: