Fix type checker errors

Pyright doesn't understand that fill_style will never be changed,
between its declaration and the inner function's scope.

    error: Argument of type "Color | None" cannot be assigned to parameter "b" of type "Color" in function "colors_match"
      Type "Color | None" cannot be assigned to type "Color"
        Type "None" cannot be assigned to type "Color" (reportGeneralTypeIssues)
This commit is contained in:
Isaiah Odhner 2023-09-22 13:28:48 -04:00
parent d8206659c6
commit 2fdb832dbd

View File

@ -186,8 +186,6 @@ def flood_fill(document: 'AnsiArtDocument', x: int, y: int, fill_ch: str, fill_f
"""Flood fill algorithm."""
fill_style = Style(color=fill_fg, bgcolor=fill_bg)
assert fill_style.color is not None
assert fill_style.bgcolor is not None
# Get the original value of the cell.
# This is the color to be replaced.
@ -225,6 +223,8 @@ def flood_fill(document: 'AnsiArtDocument', x: int, y: int, fill_ch: str, fill_f
assert color is not None
assert original_style.bgcolor is not None
assert original_style.color is not None
assert fill_style.color is not None
assert fill_style.bgcolor is not None
return (
document.ch[y][x] == original_ch and
colors_match(bgcolor, original_style.bgcolor) and