zulip/zproject
Zixuan James Li fe9ed2e69d settings: Make INVITATION_LINK_VALIDITY_MINUTES optional.
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>
2022-07-26 17:07:48 -07:00
..
jinja2 requirements: Upgrade Python requirements. 2022-07-05 17:54:17 -07:00
__init__.py Rename Django project to zproject. 2013-08-07 11:04:03 -04:00
backends.py custom_profile: Apply ProfileDataElementUpdateDict. 2022-07-15 14:55:03 -07:00
computed_settings.py settings: Make INVITATION_LINK_VALIDITY_MINUTES optional. 2022-07-26 17:07:48 -07:00
config.py sentry: Set environment from machine.deploy_type config. 2021-07-15 15:01:43 -07:00
configured_settings.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
default_settings.py settings: Add CUSTOM_HOME_NOT_LOGGED_IN for type narrowing. 2022-07-25 14:11:32 -07:00
dev_settings.py settings: Add CUSTOM_HOME_NOT_LOGGED_IN for type narrowing. 2022-07-25 14:11:32 -07:00
dev_urls.py typing: Fix function signatures with django-stubs. 2021-08-20 06:02:55 -07:00
email_backends.py email_backends: Fix concurrent backend testing for generate_emails. 2022-05-03 08:45:51 -07:00
legacy_urls.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
prod_settings_template.py prod_settings_template: Switch to double quotes in commented lines. 2022-04-28 12:40:28 -07:00
prod_settings.pyi zproject: Add prod_settings mypy stub, aliasing prod_settings_template. 2021-07-05 09:53:41 -07:00
sentry.py requirements: Upgrade Python requirements. 2022-06-01 16:01:54 -07:00
settings.py python: Add noqa comments for the specific star imports we allow. 2020-06-11 15:36:43 -07:00
test_extra_settings.py scim: Add SCIMConfigDict. 2022-07-15 14:00:56 -07:00
test_settings.py test_settings: Use TEST_EXTERNAL_HOST to override ‘testserver’ default. 2020-12-17 13:07:59 -08:00
urls.py emoji: Use path converter for emoji name in URL. 2022-07-14 14:29:40 -07:00
wsgi.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00