You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use WithAnnotations as well as a typedict and hope for correctly typing the extra fields added to a model through annotations in its manager. Although mypy is happy with this typing, the language server used by VS Code, Pylance, does not think it valid. I had an type error warning, saying "Too many type arguments provided for 'type[_T@WithAnnotations]'; expected 1 but received 2". I turned off the Pylance type check by editing settings.json and added the section like below.
The error warning disappeared. But the intelliSense still can not infer the type of those fields. They are typed with any.
I would like to know is there any way to make VS Code aware of those annotated fields? Thanks a lot.
Edit:
Actually I then got a runtime error when executing manage.py commands. The workaround in the comment helps to bypass the runtime error. But still, the types of annotated fields are any.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I use WithAnnotations as well as a typedict and hope for correctly typing the extra fields added to a model through annotations in its manager. Although mypy is happy with this typing, the language server used by VS Code, Pylance, does not think it valid. I had an type error warning, saying "Too many type arguments provided for 'type[_T@WithAnnotations]'; expected 1 but received 2". I turned off the Pylance type check by editing settings.json and added the section like below.
The error warning disappeared. But the intelliSense still can not infer the type of those fields. They are typed with any.
I would like to know is there any way to make VS Code aware of those annotated fields? Thanks a lot.
Edit:
Actually I then got a runtime error when executing manage.py commands. The workaround in the comment helps to bypass the runtime error. But still, the types of annotated fields are any.
Beta Was this translation helpful? Give feedback.
All reactions