Skip to content

Commit

Permalink
Bump pillow + minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
einarf committed Oct 14, 2023
1 parent 2a89ba0 commit f527bc4
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 112 deletions.
178 changes: 89 additions & 89 deletions moderngl_window/context/base/keys.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# flake8: noqa E741

from typing import Any

class KeyModifiers:
"""Namespace for storing key modifiers"""

shift = False
ctrl = False
alt = False
shift: Any = False
ctrl: Any = False
alt: Any = False

def __repr__(self):
return str(self)
Expand All @@ -24,94 +24,94 @@ class BaseKeys:
"""

# Fallback press/release action when window libraries don't have this
ACTION_PRESS = "ACTION_PRESS"
ACTION_RELEASE = "ACTION_RELEASE"
ACTION_PRESS: Any = "ACTION_PRESS"
ACTION_RELEASE: Any = "ACTION_RELEASE"

ESCAPE = None
SPACE = None
ENTER = None
PAGE_UP = None
PAGE_DOWN = None
LEFT = None
RIGHT = None
UP = None
DOWN = None
ESCAPE: Any = "undefined"
SPACE: Any = "undefined"
ENTER: Any = "undefined"
PAGE_UP: Any = "undefined"
PAGE_DOWN: Any = "undefined"
LEFT: Any = "undefined"
RIGHT: Any = "undefined"
UP: Any = "undefined"
DOWN: Any = "undefined"

TAB = None
COMMA = None
MINUS = None
PERIOD = None
SLASH = None
SEMICOLON = None
EQUAL = None
LEFT_BRACKET = None
RIGHT_BRACKET = None
BACKSLASH = None
BACKSPACE = None
INSERT = None
DELETE = None
HOME = None
END = None
CAPS_LOCK = None
TAB: Any = "undefined"
COMMA: Any = "undefined"
MINUS: Any = "undefined"
PERIOD: Any = "undefined"
SLASH: Any = "undefined"
SEMICOLON: Any = "undefined"
EQUAL: Any = "undefined"
LEFT_BRACKET: Any = "undefined"
RIGHT_BRACKET: Any = "undefined"
BACKSLASH: Any = "undefined"
BACKSPACE: Any = "undefined"
INSERT: Any = "undefined"
DELETE: Any = "undefined"
HOME: Any = "undefined"
END: Any = "undefined"
CAPS_LOCK: Any = "undefined"

F1 = None
F2 = None
F3 = None
F4 = None
F5 = None
F6 = None
F7 = None
F8 = None
F9 = None
F10 = None
F11 = None
F12 = None
F1: Any = "undefined"
F2: Any = "undefined"
F3: Any = "undefined"
F4: Any = "undefined"
F5: Any = "undefined"
F6: Any = "undefined"
F7: Any = "undefined"
F8: Any = "undefined"
F9: Any = "undefined"
F10: Any = "undefined"
F11: Any = "undefined"
F12: Any = "undefined"

NUMBER_0 = None
NUMBER_1 = None
NUMBER_2 = None
NUMBER_3 = None
NUMBER_4 = None
NUMBER_5 = None
NUMBER_6 = None
NUMBER_7 = None
NUMBER_8 = None
NUMBER_9 = None
NUMBER_0: Any = "undefined"
NUMBER_1: Any = "undefined"
NUMBER_2: Any = "undefined"
NUMBER_3: Any = "undefined"
NUMBER_4: Any = "undefined"
NUMBER_5: Any = "undefined"
NUMBER_6: Any = "undefined"
NUMBER_7: Any = "undefined"
NUMBER_8: Any = "undefined"
NUMBER_9: Any = "undefined"

NUMPAD_0 = None
NUMPAD_1 = None
NUMPAD_2 = None
NUMPAD_3 = None
NUMPAD_4 = None
NUMPAD_5 = None
NUMPAD_6 = None
NUMPAD_7 = None
NUMPAD_8 = None
NUMPAD_9 = None
NUMPAD_0: Any = "undefined"
NUMPAD_1: Any = "undefined"
NUMPAD_2: Any = "undefined"
NUMPAD_3: Any = "undefined"
NUMPAD_4: Any = "undefined"
NUMPAD_5: Any = "undefined"
NUMPAD_6: Any = "undefined"
NUMPAD_7: Any = "undefined"
NUMPAD_8: Any = "undefined"
NUMPAD_9: Any = "undefined"

A = None
B = None
C = None
D = None
E = None
F = None
G = None
H = None
I = None
J = None
K = None
L = None
M = None
N = None
O = None
P = None
Q = None
R = None
S = None
T = None
U = None
V = None
W = None
X = None
Y = None
Z = None
A: Any = "undefined"
B: Any = "undefined"
C: Any = "undefined"
D: Any = "undefined"
E: Any = "undefined"
F: Any = "undefined"
G: Any = "undefined"
H: Any = "undefined"
I: Any = "undefined"
J: Any = "undefined"
K: Any = "undefined"
L: Any = "undefined"
M: Any = "undefined"
N: Any = "undefined"
O: Any = "undefined"
P: Any = "undefined"
Q: Any = "undefined"
R: Any = "undefined"
S: Any = "undefined"
T: Any = "undefined"
U: Any = "undefined"
V: Any = "undefined"
W: Any = "undefined"
X: Any = "undefined"
Y: Any = "undefined"
Z: Any = "undefined"
22 changes: 11 additions & 11 deletions moderngl_window/context/base/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BaseWindow:
"""

#: Name of the window. For example ``pyglet``, ``glfw``
name = None
name = "base"
#: Window specific key constants
keys = BaseKeys
#: Mouse button enum
Expand Down Expand Up @@ -1218,7 +1218,7 @@ def load_texture_2d(
flip_x=False,
flip_y=True,
mipmap=False,
mipmap_levels: Tuple[int, int] = None,
mipmap_levels: Optional[Tuple[int, int]] = None,
anisotropy=1.0,
**kwargs
) -> moderngl.Texture:
Expand Down Expand Up @@ -1262,7 +1262,7 @@ def load_texture_array(
layers: int = 0,
flip=True,
mipmap=False,
mipmap_levels: Tuple[int, int] = None,
mipmap_levels: Optional[Tuple[int, int]] = None,
anisotropy=1.0,
**kwargs
) -> moderngl.TextureArray:
Expand Down Expand Up @@ -1307,17 +1307,17 @@ def load_texture_array(

def load_texture_cube(
self,
pos_x: str = None,
pos_y: str = None,
pos_z: str = None,
neg_x: str = None,
neg_y: str = None,
neg_z: str = None,
pos_x: str = "",
pos_y: str = "",
pos_z: str = "",
neg_x: str = "",
neg_y: str = "",
neg_z: str = "",
flip=False,
flip_x=False,
flip_y=False,
mipmap=False,
mipmap_levels: Tuple[int, int] = None,
mipmap_levels: Optional[Tuple[int, int]] = None,
anisotropy=1.0,
**kwargs
) -> moderngl.TextureCube:
Expand Down Expand Up @@ -1373,7 +1373,7 @@ def load_program(
fragment_shader=None,
tess_control_shader=None,
tess_evaluation_shader=None,
defines: dict = None,
defines: Optional[dict] = None,
varyings: Optional[List[str]] = None,
) -> moderngl.Program:
"""Loads a shader program.
Expand Down
3 changes: 1 addition & 2 deletions moderngl_window/loaders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class BaseLoader:
"""Base loader class for all resources"""

kind = None
kind = "unknown"
"""
The kind of resource this loaded supports.
This can be used when file extensions is not enough
Expand Down
8 changes: 3 additions & 5 deletions moderngl_window/loaders/scene/gltf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,7 @@ def version(self):

def check_version(self, required="2.0"):
if not self.version == required:
msg = "GLTF Format version is not 2.0. Version states '{}' in file {}".format(
self.version, self.path,
)
msg = f"GLTF Format version is not 2.0. Version states '{self.version}' in file {self.path}"
raise ValueError(msg)

def check_extensions(self, supported):
Expand All @@ -400,12 +398,12 @@ def check_extensions(self, supported):
if self.data.get("extensionsRequired"):
for ext in self.data.get("extensionsRequired"):
if ext not in supported:
raise ValueError("Extension {} not supported".format(ext))
raise ValueError(f"Extension {ext} not supported")

if self.data.get("extensionsUsed"):
for ext in self.data.get("extensionsUsed"):
if ext not in supported:
raise ValueError("Extension {} not supported".format(ext))
raise ValueError("Extension {ext} not supported")

def buffers_exist(self):
"""Checks if the bin files referenced exist"""
Expand Down
2 changes: 1 addition & 1 deletion moderngl_window/loaders/texture/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _load_face(self, path: str, face_name: str = None):
Tuple[int, bytes]: number of components, byte data
"""
if not path:
raise ImproperlyConfigured("{} texture face not supplied".format(face_name))
raise ImproperlyConfigured(f"{face_name} texture face not supplied")

image = self._load_texture(path)
components, data = image_data(image)
Expand Down
4 changes: 2 additions & 2 deletions moderngl_window/meta/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class ResourceDescription:
This class can be extended to add more specific properties.
"""

default_kind = None # The default kind of loader
default_kind = "" # The default kind of loader
"""str: The default kind for this resource type"""
resource_type = None # What resource type is described
resource_type = "" # What resource type is described
"""str: A unique identifier for the resource type"""

def __init__(self, **kwargs):
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"pyglet~=2.0.0",
"numpy>=1.16,<2",
"pyrr>=0.10.3,<1",
"Pillow>=9,<10",
"Pillow~=10.0.1",
]

[tool.setuptools.packages.find]
Expand Down Expand Up @@ -77,8 +77,8 @@ ignore = [
"W503",
"C901",
]
max-complexity = 10
max-line-length = 120
max-complexity = 10
exclude = [
"tests/",
"docs/",
Expand Down Expand Up @@ -131,3 +131,7 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "pyrr.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "trimesh.*"
ignore_missing_imports = true
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# All values are merged into pyproject.toml, but
# as of flake8 6.1 it still doesn't read config
# from the tool.flake8 namespace in pyproject.toml

[flake8]
max-line-length = 120
max-complexity = 10

0 comments on commit f527bc4

Please sign in to comment.