Fix type errors with newest mypy.
This commit is contained in:
parent
e30dcb2884
commit
284153ef2e
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user