mirror of
https://github.com/zulip/zulip.git
synced 2026-06-30 21:11:04 +08:00
Type inference does not work when the default value of `REQ` is non-optional while `ResultT` is optional. Mypy tries to unify `json_validator` with `Validator[int]` in `invite_users_backend` instead of the desired `Validator[Optional[int]]` because of the presence of the default value `settings.INVITATION_LINK_VALIDITY_MINUTES`, which is inferred to be an `int`. Mypy does not resort to a less specific type but instead gives up early. This issue applies to invite_users_backend and generate_multiuse_invite_backend in zerver.views.invite. There might be a way that we can add an overload to get around this, but it's probably not worth the complexity until it comes up again more frequently. We do in fact allow `invite_expires_in_minutes` to be `None` in places like `do_invite_users`, `invite_users_backend`, etc, and we have `settings.INVITATION_LINK_VALIDITY_MINUTES` as the default for them. So it makes sense to allow having an optional value for this setting. And since there isn't a way to independently set the value of this constant, we move it to a different place. TODO: This is a temporary fix that should be refactored when the bug is fixed. The encountered mypy issue: https://github.com/python/mypy/issues/13234 Signed-off-by: Zixuan James Li <p359101898@gmail.com> |
||
|---|---|---|
| .. | ||
| jinja2 | ||
| __init__.py | ||
| backends.py | ||
| computed_settings.py | ||
| config.py | ||
| configured_settings.py | ||
| default_settings.py | ||
| dev_settings.py | ||
| dev_urls.py | ||
| email_backends.py | ||
| legacy_urls.py | ||
| prod_settings_template.py | ||
| prod_settings.pyi | ||
| sentry.py | ||
| settings.py | ||
| test_extra_settings.py | ||
| test_settings.py | ||
| urls.py | ||
| wsgi.py | ||