We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TextChoices
According to the django docs, this should be allowed:
class YearInSchool(models.TextChoices): FRESHMAN = "FR", _("Freshman") SOPHOMORE = "SO", _("Sophomore") JUNIOR = "JR", _("Junior") SENIOR = "SR", _("Senior") GRADUATE = "GR", _("Graduate")
but since the constructor for Textchoices is defined like this:
def __new__(cls, value: str) -> Self: ...
This is rejected by pyright in some situations. (I can talk about my setup some more, but in my personal situation it's not easy to work around)
Or maybe the constructor is not involved in this at all? Pyright gives me this not-really-helpful error:
/path/to/models.py /path/to/models.py:40:19 - error: Expected 1 positional argument (reportCallIssue) /path/to/models.py:41:50 - error: Expected 1 positional argument (reportCallIssue) 2 errors, 0 warnings, 0 informations ``
The text was updated successfully, but these errors were encountered:
Hi, we're also experiencing this since 4.2.6. Here is a minimal example to reproduce the error:
from django.db.models import TextChoices class MyChoices(TextChoices): CHOICE = "CHOICE", "A choice"
django: 4.2.11 python: 3.10
Result: /test_file.py:5:14 - error: Expected 1 positional argument (reportCallIssue)
/test_file.py:5:14 - error: Expected 1 positional argument (reportCallIssue)
I've initially wrongly reported this to pyright.
Sorry, something went wrong.
Fix 'reportCallIssues' with pyright
0294d7e
Fixes typeddjango#2033.
TextChoices.__new__()
Fix 'reportCallIssues' with pyright (#2156)
be51acb
Fixes #2033.
Successfully merging a pull request may close this issue.
According to the django docs, this should be allowed:
but since the constructor for Textchoices is defined like this:
This is rejected by pyright in some situations. (I can talk about my setup some more, but in my personal situation it's not easy to work around)
Or maybe the constructor is not involved in this at all? Pyright gives me this not-really-helpful error:
The text was updated successfully, but these errors were encountered: