nutti / fake-bpy-module

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

bpy_types contains duplicates of classes in bpy.types with poor typing that are sometimes used instead #252

Closed Road-hog123 closed 3 weeks ago

Road-hog123 commented 3 weeks ago

I noticed while testing for #250 that bl_ui.generic_ui_list.draw_ui_list()'s context argument was sometimes typed as bpy_types.Context and sometimes as bpy.types.Context, and the change didn't seem to be consistent with the package version changes I was making.

Testing again now, I generated 9 theoretically identical modules, each into a different directory, without making any changes, and three of them used bpy_types while the rest used bpy.types, with no other differences.

I feel like the generated output should at least be consistent, it would make it easier to test if changes have unintended side effects.

Usage of bpy_types is limited to bl_ui, bl_operators and keyingsets_builtins—I have no experience with these parts of the API.

nutti commented 3 weeks ago

@Road-hog123

Thanks for finding this issue. Should we remove the bpy_types module and replace bpy_types to bpy.types for all type annotations?

Road-hog123 commented 3 weeks ago

It is possible to import bpy_types within Blender, so I'm not sure it should be removed.

There are a few classes that are unique to bpy_types—as far as I can tell _GenericUI is the only one that is used currently, but that may have been different in older versions or change in the future. Would it be possible for the generation code to do a set intersection or something to determine which classes should be redirected?

nutti commented 3 weeks ago

Fixed this issue.