django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

Missing editor hints when creating new instance

Open torx-cz opened this issue 1 year ago • 1 comments

Hello

I would like to ask if it is possible to "turn on" (somehow) the ability to see editor hints when creating new instances of Schemas.

For example, see this code:

import pydantic
import ninja

class PydanticModel(pydantic.BaseModel):
    a: int = 0
    b: str

class NinjaSchema(ninja.Schema):
    a: int = 0
    b: str

PydanticModel()
NinjaSchema()

When i write this code in VS Code i can see this for PydanticModel() (when hover over + red line under it, signaling something is wrong!)

pydantic_model

But for NinjaSchema() i see only this:

ninja_schema


My question is: Is there some way to turn on the same behavior for NinjaSchemas like it is for PydanticModel? Namely:

  • when hover over - to be able to see which params need to be defined (not just **data: Any)
  • red line under when something is wrong

Thank you very much!

torx-cz avatar Jan 17 '24 08:01 torx-cz

Hi @torx-cz

yeah indeed - I did not notice that before - and it is interesting to find out what's the trick (as Schema is just inherited from the BaseModel... maybe metaclass helps here)

vitalik avatar Jan 17 '24 09:01 vitalik