1
0
mirror of synced 2025-01-31 12:13:49 +01:00

Fix type errors with newest mypy.

This commit is contained in:
Jennifer Taylor 2023-02-17 03:32:27 +00:00
parent e30dcb2884
commit 284153ef2e
9 changed files with 21 additions and 30 deletions

View File

@ -1,5 +1,5 @@
from datetime import datetime
from discord_webhook import DiscordWebhook, DiscordEmbed # type: ignore
from discord_webhook import DiscordWebhook, DiscordEmbed
from typing import Dict
from bemani.common.constants import GameConstants, BroadcastConstants

View File

@ -1,6 +1,6 @@
import multiprocessing
import signal
from PIL import Image # type: ignore
from PIL import Image
from typing import Any, Callable, List, Optional, Sequence, Union
from ..types import Color, HSL, Matrix, Point, AAMode
@ -580,7 +580,7 @@ def affine_composite(
cores = multiprocessing.cpu_count()
if single_threaded or cores < 2:
# Get the data in an easier to manipulate and faster to update fashion.
imgbytes = bytearray(img.tobytes("raw", "RGBA"))
imgbytearray = bytearray(img.tobytes("raw", "RGBA"))
texbytes = texture.tobytes("raw", "RGBA")
if mask:
alpha = mask.split()[-1]
@ -593,7 +593,7 @@ def affine_composite(
for imgx in range(minx, maxx):
# Determine offset
imgoff = (imgx + (imgy * imgwidth)) * 4
imgbytes[imgoff : (imgoff + 4)] = pixel_renderer(
imgbytearray[imgoff : (imgoff + 4)] = pixel_renderer(
imgx,
imgy,
imgwidth,
@ -607,13 +607,13 @@ def affine_composite(
mult_color,
hsl_shift,
blendfunc,
imgbytes,
imgbytearray,
texbytes,
maskbytes,
aa_mode,
)
img = Image.frombytes("RGBA", (imgwidth, imgheight), bytes(imgbytes))
img = Image.frombytes("RGBA", (imgwidth, imgheight), bytes(imgbytearray))
else:
imgbytes = img.tobytes("raw", "RGBA")
texbytes = texture.tobytes("raw", "RGBA")
@ -792,15 +792,6 @@ def perspective_composite(
# This texture is entirely off of the screen.
return img
# Get the data in an easier to manipulate and faster to update fashion.
imgbytes = bytearray(img.tobytes("raw", "RGBA"))
texbytes = texture.tobytes("raw", "RGBA")
if mask:
alpha = mask.split()[-1]
maskbytes = alpha.tobytes("raw", "L")
else:
maskbytes = None
def perspective_inverse(imgpoint: Point) -> Optional[Point]:
# Calculate the texture coordinate with our perspective interpolation.
texdiv = inverse_matrix.multiply_point(imgpoint)
@ -812,7 +803,7 @@ def perspective_composite(
cores = multiprocessing.cpu_count()
if single_threaded or cores < 2:
# Get the data in an easier to manipulate and faster to update fashion.
imgbytes = bytearray(img.tobytes("raw", "RGBA"))
imgbytearray = bytearray(img.tobytes("raw", "RGBA"))
texbytes = texture.tobytes("raw", "RGBA")
if mask:
alpha = mask.split()[-1]
@ -825,7 +816,7 @@ def perspective_composite(
for imgx in range(minx, maxx):
# Determine offset
imgoff = (imgx + (imgy * imgwidth)) * 4
imgbytes[imgoff : (imgoff + 4)] = pixel_renderer(
imgbytearray[imgoff : (imgoff + 4)] = pixel_renderer(
imgx,
imgy,
imgwidth,
@ -839,13 +830,13 @@ def perspective_composite(
mult_color,
hsl_shift,
blendfunc,
imgbytes,
imgbytearray,
texbytes,
maskbytes,
aa_mode,
)
img = Image.frombytes("RGBA", (imgwidth, imgheight), bytes(imgbytes))
img = Image.frombytes("RGBA", (imgwidth, imgheight), bytes(imgbytearray))
else:
imgbytes = img.tobytes("raw", "RGBA")
texbytes = texture.tobytes("raw", "RGBA")

View File

@ -1,4 +1,4 @@
from PIL import Image # type: ignore
from PIL import Image
from typing import Optional
from ..types import Color, HSL, Point, Matrix

View File

@ -1,5 +1,5 @@
import multiprocessing
from PIL import Image # type: ignore
from PIL import Image
from typing import Optional, Tuple
from ..types import Color, HSL, Matrix, Point, AAMode

View File

@ -1,7 +1,7 @@
import io
import os
import struct
from PIL import Image # type: ignore
from PIL import Image
from typing import Any, Dict, List, Optional, Tuple
from bemani.format.dxt import DXTBuffer

View File

@ -1,5 +1,5 @@
from typing import Any, Dict, Generator, List, Set, Tuple, Optional, Union
from PIL import Image # type: ignore
from PIL import Image
from .blend import affine_composite, perspective_composite
from .swf import (
@ -85,7 +85,7 @@ class RegisteredShape:
self.tex_points: List[Point] = tex_points
self.tex_colors: List[Color] = tex_colors
self.draw_params: List[DrawParams] = draw_params
self.rectangle: Optional[Image.image] = None
self.rectangle: Optional[Image.Image] = None
@property
def reference(self) -> str:

View File

@ -2,7 +2,7 @@ import hashlib
import io
import os
import struct
from PIL import Image # type: ignore
from PIL import Image
from typing import Callable, Dict, List, Optional, Tuple
from bemani.format.dxt import DXTBuffer

View File

@ -7,7 +7,7 @@ import os
import os.path
import sys
import textwrap
from PIL import Image, ImageDraw # type: ignore
from PIL import Image, ImageDraw
from typing import Any, Dict, List, Optional, Tuple, TypeVar
from bemani.format.afp import (
@ -555,8 +555,8 @@ def load_containers(
# Load file, register it.
fdata = ifsfile.read_file(fname)
tex = Image.open(io.BytesIO(fdata))
renderer.add_texture(texname, tex)
teximg = Image.open(io.BytesIO(fdata))
renderer.add_texture(texname, teximg)
if verbose:
print(
@ -872,7 +872,7 @@ def render_path(
# Write all the frames out in one file.
duration = renderer.compute_path_frame_duration(path)
frames = renderer.compute_path_frames(path)
images: List[Image] = []
images: List[Image.Image] = []
for i, img in enumerate(
renderer.render_path(
path,

View File

@ -3,7 +3,7 @@
import argparse
import os
import xml.etree.ElementTree as ET
from PIL import Image # type: ignore
from PIL import Image
from typing import Dict, Optional
from bemani.common import GameConstants, VersionConstants