]> Untitled Git - axy/ft/pacman.git/commitdiff
Partial cleanup
authorAxy <gilliardmarthey.axel@gmail.com>
Tue, 22 Sep 2026 23:10:10 +0000 (01:10 +0200)
committerAxy <gilliardmarthey.axel@gmail.com>
Tue, 22 Sep 2026 23:10:10 +0000 (01:10 +0200)
.flake8 [new file with mode: 0644]
src/pacman/ecs/__init__.py
src/pacman/ecs/world.py

diff --git a/.flake8 b/.flake8
new file mode 100644 (file)
index 0000000..0081794
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,2 @@
+[flake8]
+ignore = E203,W503
index c23136385bb389e045898277aae6499bb63c3465..67c5ba7448ce19a2eb1050bf32f118bb239264b6 100644 (file)
@@ -17,7 +17,6 @@ from pacman.ecs.schedule import (
 )
 from pacman.ecs.world import (
     Component,
-    Entity,
     Not,
     Query,
     Resource,
index 7f0a8624c90419fdb5f2311e9f5379941a388b0e..9327c9cd0e0c67b6913f315223607cd1691abcf9 100644 (file)
@@ -1,17 +1,14 @@
 import inspect
-from abc import abstractmethod
+from abc import ABC, abstractmethod
 from collections.abc import Callable, Container, Iterable, Iterator
-from dataclasses import dataclass
 from typing import (
     Any,
     Literal,
-    Protocol,
     Self,
     Union,
     cast,
     get_args,
     override,
-    runtime_checkable,
 )
 
 from pacman.ecs.schedule import (
@@ -28,12 +25,7 @@ from pacman.utils.variadics_please import (
 )
 
 
-@dataclass
-class Resource2[T]:
-    storage: type[T]
-
-
-class ComponentLike(Protocol):
+class Bundle(ABC):
     @abstractmethod
     def components_iter(self) -> Iterator["Component"]: ...
     @classmethod
@@ -41,7 +33,7 @@ class ComponentLike(Protocol):
     def components_type_iter(cls) -> Iterator[type["Component"]]: ...
 
 
-type Components = RecursiveTuple["Component | ComponentLike"]
+type Components = RecursiveTuple["Component | Bundle"]
 
 
 def components_iter(components: Components) -> Iterator["Component"]:
@@ -65,7 +57,7 @@ def components_type_iter(
     elif issubclass(components, Component):
         yield components
     else:
-        yield from cast(type[ComponentLike], components).components_type_iter()
+        yield from cast(type[Bundle], components).components_type_iter()
 
 
 class Archetype:
@@ -202,8 +194,7 @@ type Plugin = RecursiveTuple[Callable[["World"], None]]
 type ComponentHook[T] = Callable[["World", "Entity", T], None]
 
 
-@runtime_checkable
-class FromWorld(Protocol):
+class FromWorld(ABC):
     @classmethod
     @abstractmethod
     def extract_from_world(
@@ -214,7 +205,7 @@ class FromWorld(Protocol):
         pass
 
 
-class QueryFilter:
+class QueryFilter(ABC):
     @classmethod
     @abstractmethod
     def filter(
@@ -542,7 +533,7 @@ class Resource(FromWorld, Component):
 
 
 class CommandQueue(FromWorld):
-    def __init__(self, world: "World"):
+    def __init__(self, world: "World") -> None:
         self._world = world
         self._queue: list[Callable[[World], Any]] = []
 
@@ -602,7 +593,7 @@ class World(FromWorld):
         ents = self.spawn_many_empty(len(comps))
         self._base_archetype.add_components(
             cast(type[Components], ty),
-            list(zip(ents, cast(list[Components], comps))),
+            list(zip(ents, cast(list[Components], comps), strict=True)),
         )
         return ents