You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
graphik.py defines __init__ twice on the Graphik class. The first definition (graphik.py:14-19) takes no arguments and creates its own 900x600 display via pygame.display.set_mode(...). The second definition (graphik.py:21-24) takes a gameDisplay argument. Python binds only the last definition, so the no-argument form is silently discarded — it is dead code that reads as though it were a supported way to construct the class.
Verification
The behavior was confirmed against the source in this repository under SDL_VIDEODRIVER=dummy:
main.py:51 is the only in-tree caller, and it passes a display, so no runtime behavior depends on the shadowed definition today.
Why it matters
Python has no constructor overloading. A reader of graphik.py is invited to believe Graphik() is valid, and any future caller written against that reading fails with a TypeError. The displayWidth / displayHeight locals in the shadowed definition also mislead, since they never take effect.
Suggested resolution
Either of the following would resolve the ambiguity:
Delete the shadowed no-argument definition, leaving __init__(self, gameDisplay) as the single documented constructor.
Merge the two into one definition with a default, e.g. __init__(self, gameDisplay=None), where a None display causes the 900x600 surface to be created. This preserves the apparent intent of the first definition, but couples Graphik to display creation, which RenderWindow (see Create a RenderWindow class to manage Pygame initialization #6) is intended to own.
Deleting the shadowed definition is the lower-risk option and is the one recommended here.
Acceptance criteria
graphik.py contains exactly one def __init__ on the Graphik class.
Whatever construction forms remain are exercised by a unit test under tests/ with pygame mocked, so no display is required.
Summary
graphik.pydefines__init__twice on theGraphikclass. The first definition (graphik.py:14-19) takes no arguments and creates its own 900x600 display viapygame.display.set_mode(...). The second definition (graphik.py:21-24) takes agameDisplayargument. Python binds only the last definition, so the no-argument form is silently discarded — it is dead code that reads as though it were a supported way to construct the class.Verification
The behavior was confirmed against the source in this repository under
SDL_VIDEODRIVER=dummy:main.py:51is the only in-tree caller, and it passes a display, so no runtime behavior depends on the shadowed definition today.Why it matters
Python has no constructor overloading. A reader of
graphik.pyis invited to believeGraphik()is valid, and any future caller written against that reading fails with aTypeError. ThedisplayWidth/displayHeightlocals in the shadowed definition also mislead, since they never take effect.Suggested resolution
Either of the following would resolve the ambiguity:
__init__(self, gameDisplay)as the single documented constructor.__init__(self, gameDisplay=None), where aNonedisplay causes the 900x600 surface to be created. This preserves the apparent intent of the first definition, but couplesGraphikto display creation, whichRenderWindow(see Create aRenderWindowclass to manage Pygame initialization #6) is intended to own.Deleting the shadowed definition is the lower-risk option and is the one recommended here.
Acceptance criteria
graphik.pycontains exactly onedef __init__on theGraphikclass.tests/withpygamemocked, so no display is required.This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson