The Wayback Machine - https://web.archive.org/web/20210109061002/https://github.com/pygame/pygame/issues/808
Skip to content
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

Most functions should accept keyword arguments #808

Open
dlon opened this issue Feb 9, 2019 · 5 comments
Open

Most functions should accept keyword arguments #808

dlon opened this issue Feb 9, 2019 · 5 comments

Comments

@dlon
Copy link
Member

@dlon dlon commented Feb 9, 2019

Some modules to start with:

  • surface
  • display
  • draw
  • color
  • font
  • rect
  • event

How?

@Bottersnike
Copy link
Member

@Bottersnike Bottersnike commented Feb 17, 2019

Looking at it, it should just require changes from METH_VARGS to METH_KEYWORDS then have https://docs.python.org/2/c-api/arg.html#c.PyArg_ParseTupleAndKeywords be used to parse the arguments.

@charlesej charlesej mentioned this issue Mar 9, 2019
36 of 36 tasks complete
@charlesej
Copy link
Contributor

@charlesej charlesej commented Mar 30, 2019

Changes for the draw module to accept keyword arguments is being done via #896.

@illume
Copy link
Member

@illume illume commented Nov 17, 2019

See rect-keyword-args branch if anyone wants to finish off the rect kwargs.

@MyreMylar
Copy link
Contributor

@MyreMylar MyreMylar commented Apr 21, 2020

Having a look at this, now I have pygame mostly building on windows.
Modelling on the work @charlesej already did, I thought I'd start by having a go at doing one simple looking function in the event module, you can see my first commit here:

master...MyreMylar:event-keyword-args

So the eventual syntax here would be:

name = pygame.event.event_name(type=pygame.MOUSEBUTTONDOWN)

it seems to work, though it is a bit of a trivial case. Was a bit unsure about specifying the 'type' of the 'type' parameter as int. I mean it is an int but most people interact with the events system through the defined constants - but that is consistent with what was added by @charlesej .

If what I've done seems OK I can go through the rest of the event module. Not sure how/if we can handle the functions with two overlapping signatures like:

set_blocked(type)
set_blocked(typelist)

But there are definitely a couple of others that could have keyword arguments added.

@MyreMylar MyreMylar self-assigned this May 16, 2020
@MyreMylar MyreMylar removed their assignment Jun 5, 2020
@MyreMylar
Copy link
Contributor

@MyreMylar MyreMylar commented Jun 5, 2020

I didn't really get very far with this one, I kept getting distracted by other things and was unable to think of neat solutions to map some c functions to python signatures. In the end my main interest was getting better auto-complete and linting support, which seems to have been largely solved by the .pyi files.

So, I'll let it go and see if anyone else has more interest in closing it off in the future.

@MightyJosip MightyJosip self-assigned this Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.