-
-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A simple start towards an implementation of import pygame.debug
#3148
base: main
Are you sure you want to change the base?
Conversation
Tinkered around with supressing deprecation warnings as part of this - but it is difficult to do in a sensible way as you can only supress python warnings by where the offending code originates, and deprecation warnings come, generally, from users using deprecated code. |
What we might be able to do fairly easily is add a specific custom python warning category that we can then filter in, or filter out by default using See an example here: https://github.com/danos/pygobject/blob/6372b569b1a9b6499ba73775350c8420017a1992/gi/gimodule.c#L684 |
import pygame.debug
import pygame.debug
I added a new warning type that is only active when pygame.debug is imported. Currently nothing uses it. |
not too sold on the name. |
I thought that initially, but only the second part on the string actually prints to the console if you create one, the first part is just the module name and in this case we actually want it to be clear it is a pygame only type of warning not a generic one that may collide or overlap with warnings from other modules. Example from my testing:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides minor notes, it would be nice if pygame.debug
was documented and not a private, obscure submodule. You can just copy the changes from my PR (requires alteration), but otherwise I like this solution.
@@ -27,3 +27,4 @@ pygame\.pypm | |||
pygame\._sdl2\.mixer | |||
pygame\.sysfont.* | |||
pygame\.docs.* | |||
pygame\.debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess that this change is here is that there's no debug.pyi
stub, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of currently, using:
import pygame.debug
pygame.do_stuff()
Works, as also:
import pygame.debug
import pygame as pg
from pygame import do_stuff
pg.do_stuff()
do_stuff()
But not:
import pygame.debug as pg
from pygame.debug import do_stuff
pg.do_stuff()
do_stuff()
What's your stance on this? If the last behavio(u)r is desired, adding
from pygame import *
Or
def __getattr__(name):
return getattr(pygame, name)
def __dir__():
return dir(pygame)
Should suffice, but if doing so, the debug.pyi
stub should be created (edit buildconfig/stubs/gen_stubs.py
to copy __init__.pyi
stub).
Was reading through PR #2944 and after seeing 43 files changed and looking over the original issue #2894 I thought perhaps it would be better to start with a smaller PR before building up to bigger systemic changes to warnings.
This PR does three things:
PygameDebugWarning
.debug.py
that imports pygame, prints the old support prompt and the output of.print_debug_info()
and sets the python warning filter level to allow the new python warning typePygameDebugWarning
.import pygame
and filters out all warnings of the new typePygameDebugWarning
.This has the benefit of being small, easier to comprehend and an easier place to start a point of discussion on the main topics that might be contentious.
Test programs:
Output of 2.
This could grow on from here adding any more esoteric/opinionated/potentially unwise usage debug warning information to the new category type.