(A clear and concise description of what the bug is.)
utils/emailsender.py:22: error: Argument "MAIL_USERNAME" to "ConnectionConfig" has incompatible type "str | None"; expected "str" [arg-type]
To Reproduce
# Ideally, a small sample program that demonstrates the problem.
# Or even better, a reproducible playground link https://mypy-play.net/ (use the "Gist" button)
if not all((
self.settings.MAIL_USERNAME,
self.settings.MAIL_PASSWORD,
self.settings.EMAIL_SUPPORT,
self.settings.MAIL_SERVER
)):
raise ValueError("Mail settings must be configured and cannot be None.")
conf = ConnectionConfig(
MAIL_USERNAME=self.settings.EMAIL_USERNAME,
MAIL_PASSWORD=self.settings.EMAIL_PASSWORD,
MAIL_PORT=self.settings.EMAIL_PORT,
MAIL_FROM=self.settings.EMAIL_SUPPORT_ADDRESS,
MAIL_SERVER=self.settings.EMAIL_SERVER,
MAIL_SSL_TLS=self.settings.EMAIL_SSL_TLS,
MAIL_STARTTLS=self.settings.EMAIL_STARTTLS,
)
This raises the warning during check
utils/emailsender.py:22: error: Argument "MAIL_USERNAME" to "ConnectionConfig" has incompatible type "str | None"; expected "str" [arg-type]
If i change it to
if (self.settings.EMAIL_USERNAME is None
or self.settings.EMAIL_PASSWORD is None
or self.settings.EMAIL_SUPPORT_ADDRESS is None
or self.settings.EMAIL_SERVER is None
):
raise ValueError("Mail settings must be configured and cannot be None.")
it reports no issues
Expected Behavior
In both cases it should not raise the warning.
Actual Behavior
Your Environment
Mypy version used:
Mypy command-line flags:
Mypy configuration options from mypy.ini (and other config files):
Bug Report
(A clear and concise description of what the bug is.)
utils/emailsender.py:22: error: Argument "MAIL_USERNAME" to "ConnectionConfig" has incompatible type "str | None"; expected "str" [arg-type]
To Reproduce
This raises the warning during check
utils/emailsender.py:22: error: Argument "MAIL_USERNAME" to "ConnectionConfig" has incompatible type "str | None"; expected "str" [arg-type]
If i change it to
it reports no issues
Expected Behavior
In both cases it should not raise the warning.
Actual Behavior
Your Environment
mypy.ini
(and other config files):