MongoEngine / MongoEngine/mongoengine

Add autocompletion for instanciation

Open
#2,869 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

On Visual Studio Code, there is no useful hint on the parameters and the type for the instanciation of the object.

Example:

from mongoengine import Document, StringField

class User(Document):  
    name = StringField(required=True)
    surname = StringField(required=False)

user = User(

HINT: (...) -> User

To have useful hint, I am doing that on my project:
Example:

from typing import Optional
from mongoengine import Document, StringField

class User(Document):  
    name = StringField(required=True)
    surname = StringField(required=False)

    def __init__(self, name: str, surname: Optional[str], *args, **kwargs):  
        super().__init__(name=name, surname=surname, *args, **kwargs) 

user = User(

HINT: (name: str, surname: str | None, ...) -> User

This is really practical but I have to do a lot of duplication of code, is there a way to propose the attributes "automatically" ? can I help you do that ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining how MongoEngine Document classes and fields are represented during Python object instantiation, then check what information Visual Studio Code can obtain for parameter hints. Done would mean determining a supported way to expose required and optional document fields in autocomplete without duplicated init methods.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python, vscode
Domain
database, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.