Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve typing hint of attributes #2868

Open
JustAnotherVeryNormalDeveloper opened this issue Jan 7, 2025 · 0 comments
Open

Improve typing hint of attributes #2868

JustAnotherVeryNormalDeveloper opened this issue Jan 7, 2025 · 0 comments

Comments

@JustAnotherVeryNormalDeveloper

When working on Visual Studio Code, the hint of the type isn't very helpful. Could we make it better ? can I help doing that ?

Example:

from mongoengine import Document, StringField


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


user = User(name="John", surname="Wick")  

user.name
user.surname

The proposition of Visual Studio Code type are:
(variable) name: StringField | Unknown
(variable) surname: StringField | Unknown

Yet, the print give a really practical type:

  • print(type(user.name)) -> <class 'str'>

I want make my code more robust and be able to see that on the values:
(variable) name: str
(variable) surname: str | None

The information that it can, or not, be None, can help a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant