PIG208
91de2cbe03
typing: Avoid scoped redefinition of different types.
...
Mypy doesn't allow redefinition of a variable using a different type
within the same scope.
https://github.com/python/mypy/issues/1174
2021-07-26 15:09:07 -07:00
PIG208
178a4b4eff
tests: Initialize requests with different post data.
...
Instead of directly changing the `POST` attribute of a request, we
utilize the `HostRequestMock` initializer to produce requests with
different post data.
2021-07-26 15:09:07 -07:00
PIG208
c3abc0b472
tests: Correctly mock and invoke view functions.
...
The decorators require the decorated function to be a valid view
function. This changes the way the mocked view functions and requests
are implemented such that we can invoke view functions without future
type errors.
2021-07-26 15:09:07 -07:00
PIG208
57f46db09f
tests: Pass HostRequestMock to export_realm.
...
`export_realm` accepts an HttpRequest as the first argument,
while `self.client_post` conflicts with it. Though the argument is
unused in `export_realm`, we keep it to be compliant with the
view function type.
2021-07-26 15:09:07 -07:00
PIG208
f280ebe4b5
decorator: Type zulip_login_required with overload.
...
As we only return the actual decorator as-is only if `function` is
`None`, we can use `@overload` to accurately annotate the return type
for the decorator.
2021-07-26 15:09:07 -07:00
PIG208
434b7e360a
populate_db: Remove unused `output`.
...
The helper function `generate_and_send_messages` receives
`self.stdout.write` from `jobs`, but it is never actually used.
2021-07-26 15:09:07 -07:00
PIG208
d2af20eb2a
typing: Do explicit type conversion when appropriate.
...
When calling some functions or assigning values to certain attributes,
the arguments/right operand do not match the exact type that the
functions/attributes expect, and thus we fix that by converting types
beforehand.
2021-07-26 15:09:07 -07:00
PIG208
cd678232bd
analytics: Extract request.user for typecheck.
2021-07-26 14:48:45 -07:00
PIG208
7d1c475f69
typing: Use assertions for function arguments.
...
Utilize the assert_is_not_None helper to eliminate errors of
'Argument x to "Foo" has incompatible type "Optional[Bar]"...'
2021-07-26 14:48:45 -07:00
PIG208
8a91d1c2b1
analytics: Fix type annotation for keys.
...
realm_data, user_data, stream_data and installation_data allow the key to
be int, str, or None.
This fix the type annotation for these dictionaries.
2021-07-26 14:48:45 -07:00
PIG208
c4179428ac
caching: Make sender type optional for flush_cache.
...
That's the correct Django interface for this function.
2021-07-26 14:48:07 -07:00
PIG208
2972e921b7
utils: Add a helper function for None-checks.
2021-07-26 14:46:45 -07:00
PIG208
df1bf9e352
analytics: Fix type annotation for sql_data_collector.
2021-07-26 14:46:45 -07:00
PIG208
cf8687662f
confirmation: Use the correct type hints for create_confirmation_link.
...
Previously we annotate the first argument as `ContentType`, which
is wrong as suggested by django-stubs.
2021-07-26 14:46:45 -07:00
Dinesh
beadb5ec7f
test_middleware: Replace logging mocks with assertLogs.
2021-07-26 14:46:01 -07:00
Dinesh
2846d18854
test_decorators: Replace webhook logger mock with assertLogs.
...
Of the two other logging mocks left in this file, one checks
a logging call isn't made and another makes sure errors
aren't allowed by raising an exception as a side_effect
to the logger.
2021-07-26 14:46:01 -07:00
Dinesh
199f522808
test_classes.py: Replace markdown_logger mock with assertLogs.
...
Set level to 'ERROR' since exceptions create logs with that level.
2021-07-26 14:46:01 -07:00
Dinesh
b195cc3635
test_push_notifications.py: Replace logging mocks with assertLogs.
...
Left the mocks which are used to assert a logging call isn't made.
2021-07-26 14:46:01 -07:00
Dinesh
e4fb2883b4
populate_db: Re-enable push_notifications logger.
...
We were disabling push_notifications logger but weren't enabling
it back. This caused failures on porting logging mocks to assertLogs
as assertLogs expects a log to be generated.
See 9c224ccdd3
for why we disable
these. (To avoid logs spam from push_notifications_logger)
2021-07-26 14:46:01 -07:00
Tim Abbott
cb998f7147
templates: Copy-edit new landing pages.
2021-07-26 09:34:48 -07:00
PIG208
c7210bfc75
docs: Update client.md for the request notes change.
...
`request.client` is no longer valid since the ZulipRequestNotes change.
This update the documentation to reflect that. And it also makes it
recommend `check_send_webhook_message` in favor of
`check_send_stream_message`.
2021-07-26 08:40:53 -07:00
Tim Abbott
779a2f3317
templates: Fix broken contributor join lines.
...
This was introduced in the previous commit.
2021-07-25 22:38:14 -07:00
Alya Abbott
91e711b461
portico: Add join links to The Zulip dev community page.
2021-07-25 22:23:02 -07:00
Tim Abbott
ba3bb38bc2
templates: Avoid direct links to chat.zulip.org.
...
We instead generally want to link to the landing page explaining the
community.
2021-07-25 22:18:04 -07:00
Tim Abbott
454a900487
docs: Replace chat-zulip-org page with /developer-community/.
2021-07-25 22:17:57 -07:00
Aman Agrawal
7d8f62e7a0
portico: Add a developer-community page.
...
This is intended to replace the ReadTheDocs page of this form, but
this commit does not yet update any links.
2021-07-25 17:01:26 -07:00
Tim Abbott
361112a08f
version: Update version and changelog after 4.5 release.
2021-07-25 16:05:22 -07:00
Alya Abbott
84c2a5e433
portico: Change Zulip Standard link on UCSD case study.
...
I think it's better for it to point to Standard for Education.
2021-07-25 09:53:30 -07:00
Tim Abbott
09b5bb7930
export: Improve error message for missing registrations.
2021-07-24 17:36:15 -07:00
Mateusz Mandera
1c64bed8e4
rate_limiter: Rate limit the /new/ endpoint.
2021-07-24 15:52:06 -07:00
Mateusz Mandera
4418aefde4
decorators: Extract rate_limit_request_by_ip function.
2021-07-24 15:52:06 -07:00
Mateusz Mandera
119f1da04a
bots: Rename is_cross_realm_bot API field to is_system_bot.
...
Cross realm bots will soon stop being a thing. This param is responsible
for displaying "System Bot" in the user info popover - so this rename is the
right way to handle the situation.
We will likely want to rename the `cross_realm_bots` section as well,
but that is a more involved API migration.
2021-07-24 15:46:40 -07:00
Mateusz Mandera
1652e5c031
test_webhooks_common: Compare users by id not email.
...
Comparing by email can be incorrect, as different UserProfile can share
the same .email if they're in different realm.
2021-07-24 15:39:00 -07:00
Mateusz Mandera
86c330b752
social_auth: Fix handling of user errors in the authentication process.
...
The code didn't account for existence of SOCIAL_AUTH_SUBDOMAIN. So the
redirects would happen to endpoints on the SOCIAL_AUTH_SUBDOMAIN, which
is incorrect. The redirects should happen to the realm from which the
user came.
2021-07-24 15:17:52 -07:00
Mateusz Mandera
388932bcc4
docs: Move docs on SOCIAL_AUTH_OIDC_FULL_NAME_VALIDATED to ReadTheDocs.
2021-07-24 15:16:13 -07:00
Mateusz Mandera
9bf84a35ef
docs: Mention auto_signup OIDC option in ReadTheDocs documentation.
2021-07-24 15:13:47 -07:00
Mateusz Mandera
0d6b1cd08b
docs: Tweak phrasing about OIDC supporting only a single provider.
...
Strictly speaking, this sentence is talking about the IdP configuration,
while the backend is just GenericOpenIdConnectBackend, so the new
phrasing is more correct.
2021-07-24 15:12:06 -07:00
PIG208
5359d20a13
webhooks: Add support to event filtering system for webhooks.
...
This add support to event filtering system for most webhooks that
require trivial changes to adapt this feature.
2021-07-24 15:10:09 -07:00
PIG208
987f859681
webhooks: Detect view function with default naming convention.
2021-07-24 15:10:09 -07:00
PIG208
66b1a4e7ca
backend: Add None-checks with assertions and if-elses.
...
This fixes a batch of mypy errors of the following format:
'Item "None" of "Optional[Something]" has no attribute "abc"'
2021-07-24 15:00:21 -07:00
PIG208
fffd4ed8d5
invitations: Correctly compare realms for revoke_user_invite.
2021-07-24 14:59:19 -07:00
PIG208
de2678a319
tests: Fix missed mypy errors in tests.
...
This fixes a batch of mypy errors of the following format:
'Item "None" of "Optional[Something]" has no attribute "abc"
as a follow-up for 9892951703
.
2021-07-24 14:59:19 -07:00
Tim Abbott
01ce58319d
mypy: Fix most AnonymousUser type errors.
...
This commit fixes several mypy errors with Django stubs, by telling
mypy that we know in a given code path that the user is authenticated.
2021-07-24 14:55:46 -07:00
Tim Abbott
4713f78d2e
mypy: Add various type-checking assertions in authentication backends.
2021-07-24 13:06:55 -07:00
Tim Abbott
c576f0c93f
mypy: Declare type for OIDC settings dictionaries.
2021-07-24 12:55:15 -07:00
Tim Abbott
d603b0641e
mypy: Extend type for post_data in send_to_push_bouncer.
2021-07-24 12:55:15 -07:00
Tim Abbott
bd134019e4
mypy: Fix return type for num_push_devices_for_user.
2021-07-24 12:55:15 -07:00
Tim Abbott
4aba6c9833
mypy: Use Sequence in push notifications types.
...
This is important for variance reasons.
2021-07-24 12:55:15 -07:00
Tim Abbott
6e26c8912e
actions: Fix stream_dict/sub_dict types and variable names.
2021-07-24 11:02:08 -07:00
Tim Abbott
3790146c75
actions: Fix typing for raw stream dictionaries.
2021-07-24 11:02:08 -07:00