Describe the bugmypy show an error message in process methods because get_components gives "object" type.
To Reproduce
from dataclasses import dataclass
from esper import World, Processor
@dataclass
class Position:
x: int = 0
@dataclass
class Velocity:
x: int
class MovementProcessor(Processor):
def process(self) -> None:
for ent, (pos, vel) in self.world.get_components(Position, Velocity):
pos.x += vel.x
world = World()
world.add_processor(MovementProcessor())
ent = world.create_entity(Position(), Velocity(1))
world.process()
pos = world.try_component(ent, Position)
if pos:
print(f"player is now {pos.x}")
$ python esper_mypy_test.py
player is now 1
$ mypy esper_mypy_test.py
esper_mypy_test.py:18: error: "object" has no attribute "x" [attr-defined]
Found 1 error in 1 file (checked 1 source file)
Expected behaviormypy should find the components types from get_components
Describe the bug mypy show an error message in
process
methods becauseget_components
gives "object" type.To Reproduce
Expected behavior mypy should find the components types from
get_components
Development environment:
Additional context possibly related to #60