VS Code underlining bpy.props defs

I have finally caved and am at least attempting to move my addon’s development into VS Code. I am being dragged into it kicking and screaming. Dependency issues have made it not make sense anymore to do it from built in text editor.

My complaint is that I have fake bpy installed but it still underlines all my IntProperty() definitions, or any bpy.props definition really. I know it has access to bpy though because intellisense is showing bpy stuff. What am I supposed to do to not have 184,342,993,830 VS Code complaints that are 0% helpful?

This is the complaint on every single bpy.props def: “Call expression not allowed in type expression”.

I can get it to go away by adding the comment it wants me to add but it would be utterly insane to add hundreds of comments to my codebase just because of an IDE’s limitation.

And I look at all these tutorials for setting this monstrosity up and none of them actually go into depth on anything whatsoever, they just show you the absolute bare minimum script with no bpy.types or bpy.props or anything.

EDIT: Well this is interesting, it has no complaint about the = version:

    SoundSequence.selected_stage_object = PointerProperty(
        type=Object,
        poll=empty_objects_poll,
        name="Selected Empty",
        description='You are supposed to link this audio object strip to an "empty" object over in 3D view',
        update=CommonUpdaters.sound_source_updater
    )

So I guess it’s only upset about the newer : method.

EDIT: I was certain that if I went to VS Code, it would SURELY be able to do codebase-wide searches. That now seems to not be the case.

EDIT: I’m pretty sure this is happening because I’m running a too-old version of Python. Which seems weird because I followed all the tutorial steps, but maybe the tutorial was old?

VS Code can do codebase-wide searches, what’s the issue you’re experiencing there?

I just figured out you’re supposed to do that over on the left, there are two different search bars. I’m getting the hang of it!

Your post caught my attention today… And let me just say, I’m a hack at python…

Updating scripts I wrote in the blender 2.76 days that used the

blah.blah = blah

had to be replaced with

blah.blah : blah

Because this was a change to python somewhere between the version of python used in blender 2.76 versus the version of python used in blender 3.4 and above.

Probably this is the cause.

Anyway, I’ll be following this post because I want to set up VS Code for blender too!

Randy

I still don’t know what the deal with this is. Python 3.12 should be recent enough right? I know I’m running that and yet it stall has entire scripts highlighted in yellow because it doesn’t like : .

The annotation syntax for property declarations is specific to bpy, not standard python, so the linter doesn’t recognize it as valid.
You can suppress the error at a file level by putting this at the top.

# pyright: reportInvalidTypeForm=false        

VSCode is not an IDE.

1 Like

Open the pylance extension settings and look for:
Python Analysis Diagnostic Severity Overrides
Click on Edit in settings.json

And then add
"reportInvalidTypeForm": false
Example:

"python.analysis.diagnosticSeverityOverrides": {  
        "reportInvalidTypeForm": false
    }

I fixed it just now by going through and adding the comment it wanted to add like 200 hundred times. It’s whatever. I guess I can add the thing you wrote, but don’t want that to shut down other useful functions.

I don’t know if it technically is or isn’t an IDE, I don’t really think it matters. Point was communicated. I know it’s not XCode or Visual Studio but it’s whatever. I just want it to work.

I’ve now spent a ton of last night and nearly all day today trying to get my imports working, to no avail. I’ve already released several mult-script addons with no problem, but the very small added complexity of multiple folders has obliterated my ability to just get the dang thing running. Basically everything is broken and I can’t get anything to work. All the Python tutorials I’ve watched are painting this picture of super easy, barely an inconvneience, but Blender just refuses to find stuff. Somehow even the style I was using on older addons doesn’t work.

It’s just that everything is broken and nothing works and nothing I am trying is taking me any steps closer to even putting a dent in this job.

Attached is screenshot of my primary init.py and how the folders are set up. all folders are only one level, so no folders within those folders.


And this is one of the versions of the catastrophic failure prints I’ve been getting all day no matter what I change. This is printed to Terminal when I try to install the addon in Blender.

Failed to import property_groups: cannot import name ‘AlvaItems’ from ‘assets’ (/Users/easystreetphotography1/Library/Application Support/Blender/4.1/scripts/addons/sorcerer/assets/init.py)

Failed to import scene_properties: attempted relative import beyond top-level package

Failed to import common_properties: attempted relative import beyond top-level package

Failed to import sequencer_updaters: attempted relative import beyond top-level package

Failed to import lighting_nodes: attempted relative import beyond top-level package

Failed to import common_operators: attempted relative import beyond top-level package

Failed to import node_operators: attempted relative import beyond top-level package

Failed to import properties_operators: attempted relative import beyond top-level package

Failed to import sequencer_operators: attempted relative import beyond top-level package

Failed to import cue_builder_ops: attempted relative import beyond top-level package

Failed to import view3d_operators: attempted relative import beyond top-level package

Failed to import panels: attempted relative import beyond top-level package

Failed to register property groups: name ‘property_groups_register’ is not defined

Failed to register scene props: name ‘scene_props_register’ is not defined

Failed to register common properties: name ‘common_properties_register’ is not defined

Failed to register sequencer updaters: name ‘sequencer_updaters_register’ is not defined

Failed to register lighting nodes: name ‘lighting_nodes_register’ is not defined

Failed to register UI lists: register_class(…): already registered as a subclass ‘COMMON_UL_group_data_list’

Failed to register common operators: name ‘common_operators_register’ is not defined

Failed to register node operators: name ‘node_operators_register’ is not defined

Failed to register props operators: name ‘props_operators_register’ is not defined

Failed to register sequencer operators: name ‘sequencer_operators_register’ is not defined

Failed to register strip formatter operators: register_class(…): already registered as a subclass ‘SEQUENCER_OT_select_by_color’

Failed to register cue builder operators: name ‘cue_builder_ops_register’ is not defined

Failed to register view3D operators: name ‘view3d_operators_register’ is not defined

Failed to register panels.py: name ‘panels_register’ is not defined

I at least seem to be moving slightly closer now by putting every single import just about out of the header, which is absolutely absurd, but apparently everything has conflicting interdepencies somehow. And it seems at least a little bit happier if I put a period in front of the folder name.

EDIT: Currently have managed to get it down to just 2 errors. Seems to be absolutely impossible to get this thing to import a .py from the same folder as the init.py. Which seems absolutely ridiculous, but that’s what I’m dealing with right now. It has zero problem importing stuff from the folders, but it refuses to find stuff in the current folder.

EDIT: I finally got it! Everything is back and it’s beautiful! Turns out it was an issue that was completely unrelated to the error messages I was receiving.