neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
939 stars 231 forks source link

Autocomplete not recognizing parameters of an instance of "StructuredNode". #757

Closed SandeshGowda-0094 closed 10 months ago

SandeshGowda-0094 commented 11 months ago

Description

When using Neomodel with certain IDEs (e.g., VSCode), autocomplete for dynamically defined properties within a class that inherits from StructuredNode is not working as expected. This issue affects the developer experience when creating instances of the class with property assignments.

Code Example

from neomodel import StructuredNode, StringProperty

class Person(StructuredNode):
    self.name = StringProperty(default=name)

# Autocomplete not recognizing 'name' in the following instance creation:
sam = Person(name='sam')

I found a way, but it's not convinient...

from neomodel import StructuredNode, StringProperty

class Person(StructuredNode):
    def __init__(self, name=None, **kwargs):
        super(Person, self).__init__(**kwargs)
        self.name = StringProperty(default=name)

# Autocomplete can now recognize when used a constructor
sam = Person(name='sam')

Expected Behavior

Autocomplete should recognize the dynamically defined property name during the creation of an instance, providing suggestions as the developer types.

I would really appreciate if any would address this issue.. it would mean a lot to developer's experience.

mariusconjeaud commented 10 months ago

Thanks for your issue.

FYI, GitHub Copilot does propose properties for autocompletion in this scenario. I know it's not exactly what you're asking, but at least it is one solution :-)

image

Otherwise, I think this is more an issue for the IDEs to fix, than neomodel. See here for VSCode for instance.