Open rvanlaar opened 1 year ago
Hmm good question, I'm not super familiar with using Pyright for type checking, I usually use it for autocomplete and run mypy in CI, but:
get_level_display
inline?Like:
class study(models.Model):
LEVEL_CHOICES = (
("e", _("Elementary"),
("h", _("HighSchool")
)
level = models.CharField(
max_length=1
choices= LEVEL_CHOICES,
blank= True)
if TYPING:
def get_level_display(self) -> SomeTypeHereIDK: ...
def info(self):
return "%s" % self.get_level_display() # ReportUnkownMemberType and ReportGeneralTypeIssues
tricky part of Django ORM are these generated / metaprogrammed/ monkey patched things that can't be expressed statically
Appreciate the response.
After trying django-types and pyright on a branch, I decided against going further with it.
The application I'm working on relies on the meta programmed parts. I don't see django-types helping me. Instead I have to sprinkle the models everywhere with backlinks, autogenerated functions, 'id' and more.
Especially since django-stubs knows how to do it.
Started using Pyright and VScode. Used mypy a lot, but since typing support in VSCode is done via pyright, here I am.
Is there a recommend pyright config?
On my Django models I have a
class Meta
defined and there's an error that: "Meta" overrides symbol of same name in class "Model"...reportIncompatibleVariableOverride
Didn't see it mentioned in the documentation. Is there a recommended way to handle this?
2. I have multiple choices. Example:
What's the recommended solution?