nutti / fake-bpy-module

Fake Blender Python API module collection for the code completion.
MIT License
1.35k stars 96 forks source link

Add defaults to keyword arguments in `bmesh` #118

Closed xixixao closed 1 year ago

xixixao commented 1 year ago

Description

All bmesh.ops take one required argument and all other arguments have defaults. This is not specified in the docs in type signatures but maybe we could special case it? The defaults can be found in the blender source (usually it's a 0, false, but for example for matrices it's Identity).

Are you willing to contribute about this feature. (Yes/No)

Yes, with some guidance

Screenshots [Optional]

Not having this leads to incorrect type errors:

Screen Shot 2022-11-04 at 18 30 43
nutti commented 1 year ago

@xixixao

The defaults can be found in the blender source

It is difficult to handle because fake-bpy-module will not check the source. If you send the patch to the Blender itself to add the default value to the document, fake-bpy-module can parse these values. I think below document is useful for the reference. https://docs.blender.org/api/current/bpy.ops.object.html#bpy.ops.object.add This API document has the default value, so we can handle it.

nutti commented 1 year ago

@xixixao

This code generates the doc itself. This file parse the bmesh_opdefines.c to generate rst file, so we need to parse source code directly.

The defaults can be found in the blender source

Could you share your idea if you have an idea to get the default value from blender source? Is default value definitely 0 or false? If all default values are 0 or false, we can handle it easily from fake-bpy-module.

xixixao commented 1 year ago

@nutti https://developer.blender.org/D16400 adds the defaults to the docs

nutti commented 1 year ago

@xixixao

Great! I think fixing to the official is better idea.

xixixao commented 1 year ago

@nutti How did you get someone from Blender to review your diffs? I've tried the devtalk forum and blender.chat but didn't get any traction on the diff so far.

nutti commented 1 year ago

@xixixao

I'm not sure when Blender developer reviews the patch. (My other patch reviews are also stopped, so we need to wait patiently.) Your action (devtalk forum and blender.chat) seems correct when the review is stopped.

nutti commented 1 year ago

The patch is now merged to the official repo. Thanks for your help @xixixao !