Closed shubb30 closed 5 months ago
Pyright's behavior here is correct. For char_field1
, you're passing values to known keyword parameters. For char_field2
, you're using a dictionary unpack operator on a dict[str, bool]
which could contain any number of items that would violate type safety for the call.
If you want to package your parameters into a dict
that can safely be used for passing arguments, you'd need to define a TypedDict
like this:
class NullBlank(TypedDict):
null: bool
blank: bool
NULL_BLANK: NullBlank = {"null": True, "blank": True}
I'll note that mypy also generates the same error as pyright here.
Describe the bug When passing in
**kwargs
for a Django Model field, Pyright is throwing a bunch of errors for every parameter ofdjango.db.models.fields.Field
that is not included in the kwargs.Code or Screenshots The below code works perfectly fine with Django.
Pyright throws the following errors:
It also errors on the fields verbose_name, name, unique_for_date, unique_for_month, unique_for_year, choices, help_text, db_column, db_comment, db_tablespace, validators, error_messages, db_collation.
Fields coded as the first example work fine, but the second throws the errors.
Installed packages.