nutti / fake-bpy-module

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

Increase type specificity for node_tree attributes #253

Closed Road-hog123 closed 3 months ago

Road-hog123 commented 3 months ago

The tool that automatically documents Blender's code is not able to distinguish the derived nodetrees from each other (although it may be possible to add this functionality), so node_tree attributes like that of Material were typed as a base NodeTree instead of the ShaderNodeTree actually returned. Additionally these attributes can return (and in some cases be set to) None.

Road-hog123 commented 3 months ago

hmm... I guess for old, unsupported Blender versions before geometry nodes were added this common mod file probably won't work properly. 😞

nutti commented 3 months ago

@Road-hog123

What error is raised?

Road-hog123 commented 3 months ago

What error is raised?

I think I was worried it would add classes on older versions where those classes didn't exist, but maybe update mod files don't do that? I have no documentation to reference. 😒

Road-hog123 commented 3 months ago

I guess if this is still open later today I'll download a pre-geometry-nodes binary and test to see what gets generated. πŸ‘ (which I should have done 2 days ago)

nutti commented 3 months ago

I think I was worried it would add classes on older versions where those classes didn't exist, but maybe update mod files don't do that? I have no documentation to reference. 😒

update does not add a class which does not exist. Maybe your mod file works correctly.

I guess if this is still open later today I'll download a pre-geometry-nodes binary and test to see what gets generated. πŸ‘ (which I should have done 2 days ago)

I will wait your test. Please tell me later if your test works correctly.

Road-hog123 commented 3 months ago

It did indeed work just fine with 2.83 πŸ‘

Following 601355e84a218a3ef651162d89ce33fb5fa70f31 ShaderNodeGroup's node_tree became NodeTree | None, and therefore I was able to remove | None and skip-refine from my modfile and still get ShaderNodeTree | None in the generated module, which is great.

However, 601355e84a218a3ef651162d89ce33fb5fa70f31 did not affect Material's node_tree, which remains NodeTreeβ€”is it intended behaviour that updating it to ShaderNodeTree results in ShaderNodeTree | None? I feel I should still need to have | None and skip-refine in my modfile for this attribute, but currently I do not.

nutti commented 3 months ago

@Road-hog123

Maybe it's a side-effect of https://github.com/nutti/fake-bpy-module/commit/601355e84a218a3ef651162d89ce33fb5fa70f31. If this becomes an issue, please let us know.

Road-hog123 commented 3 months ago

Well I won't rely on that behaviour then, in case it changes in the future. πŸ‘

nutti commented 3 months ago

@Road-hog123 Thank you!