From a5596011a0d70762fe7bfdae03286a1ca4cb74cf Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 6 Aug 2019 18:44:04 -0700 Subject: [PATCH] queue_processors, python_examples: Fix mypy errors. zerver/openapi/python_examples.py:105: error: Argument 1 to "get_user_presence" of "Client" has incompatible type "str"; expected "Dict[str, Any]" zerver/openapi/python_examples.py:563: error: Argument 1 to "add_reaction" of "Client" has incompatible type "Dict[str, object]"; expected "Dict[str, str]" zerver/openapi/python_examples.py:576: error: Argument 1 to "remove_reaction" of "Client" has incompatible type "Dict[str, object]"; expected "Dict[str, str]" zerver/worker/queue_processors.py:587: error: Argument "client" to "extract_query_without_mention" has incompatible type "EmbeddedBotHandler"; expected "ExternalBotHandler" These were only missed because mypy daemon mode requires us to set `follow_imports = skip` for the `zulip` package. Signed-off-by: Anders Kaseorg --- mypy.ini | 6 ++++++ requirements/common.in | 4 ++-- requirements/dev.txt | 5 ++--- requirements/prod.txt | 5 ++--- version.py | 2 +- zerver/openapi/python_examples.py | 4 ++-- zerver/worker/queue_processors.py | 4 ++-- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mypy.ini b/mypy.ini index 6f8caddef1..8b2d4388e6 100644 --- a/mypy.ini +++ b/mypy.ini @@ -96,6 +96,12 @@ follow_imports = skip [mypy-zulint.printer] follow_imports = skip +[mypy-zulip_bots.custom_exceptions] +follow_imports = skip + +[mypy-zulip_bots.lib] +follow_imports = skip + # # diff --git a/requirements/common.in b/requirements/common.in index 5e6b61ee99..e9ed452b41 100644 --- a/requirements/common.in +++ b/requirements/common.in @@ -132,8 +132,8 @@ python-magic==0.4.15 # these tightly, including fetching content not included in the normal # release tarballs (which is a bug). So we need to pin it makes sense # to pin a version from Git rather than a release. --e "git+https://github.com/zulip/python-zulip-api.git@0.6.1#egg=zulip==0.6.1_git&subdirectory=zulip" --e "git+https://github.com/zulip/python-zulip-api.git@0.6.1#egg=zulip_bots==0.6.1+git&subdirectory=zulip_bots" +-e "git+https://github.com/zulip/python-zulip-api.git@804501610b6a205334e71b4e441fca60acf650da#egg=zulip==0.6.1_git&subdirectory=zulip" +-e "git+https://github.com/zulip/python-zulip-api.git@804501610b6a205334e71b4e441fca60acf650da#egg=zulip_bots==0.6.1+git&subdirectory=zulip_bots" # Used for Hesiod lookups, etc. py3dns==3.2.0 diff --git a/requirements/dev.txt b/requirements/dev.txt index 953ec0b937..e4de19109b 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -14,8 +14,8 @@ git+https://github.com/zulip/line_profiler.git#egg=line_profiler==2.1.2.zulip1 git+https://github.com/zulip/talon.git@7d8bdc4dbcfcc5a73298747293b99fe53da55315#egg=talon==1.2.10.zulip1 git+https://github.com/zulip/ultrajson@70ac02bec#egg=ujson==1.35+git git+https://github.com/zulip/zulint@aaed679f1ad38b230090eadd3870b7682500f60c#egg=zulint==0.0.1 -git+https://github.com/zulip/python-zulip-api.git@0.6.1#egg=zulip==0.6.1_git&subdirectory=zulip -git+https://github.com/zulip/python-zulip-api.git@0.6.1#egg=zulip_bots==0.6.1+git&subdirectory=zulip_bots +git+https://github.com/zulip/python-zulip-api.git@804501610b6a205334e71b4e441fca60acf650da#egg=zulip==0.6.1_git&subdirectory=zulip +git+https://github.com/zulip/python-zulip-api.git@804501610b6a205334e71b4e441fca60acf650da#egg=zulip_bots==0.6.1+git&subdirectory=zulip_bots alabaster==0.7.12 # via sphinx apns2==0.5.0 argon2-cffi==19.1.0 @@ -179,7 +179,6 @@ twilio==6.29.2 twisted==19.2.1 typed-ast==1.4.0 # via mypy typing-extensions==3.7.4 -typing==3.6.6 urllib3==1.25.3 # via botocore, requests, transifex-client virtualenv-clone==0.5.3 w3lib==1.20.0 # via parsel, scrapy diff --git a/requirements/prod.txt b/requirements/prod.txt index 7e4ad5c840..1e45d44562 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -13,8 +13,8 @@ git+https://github.com/zulip/libthumbor.git@60ed2431c07686a12f2770b2d852c5650f3c git+https://github.com/zulip/line_profiler.git#egg=line_profiler==2.1.2.zulip1 git+https://github.com/zulip/talon.git@7d8bdc4dbcfcc5a73298747293b99fe53da55315#egg=talon==1.2.10.zulip1 git+https://github.com/zulip/ultrajson@70ac02bec#egg=ujson==1.35+git -git+https://github.com/zulip/python-zulip-api.git@0.6.1#egg=zulip==0.6.1_git&subdirectory=zulip -git+https://github.com/zulip/python-zulip-api.git@0.6.1#egg=zulip_bots==0.6.1+git&subdirectory=zulip_bots +git+https://github.com/zulip/python-zulip-api.git@804501610b6a205334e71b4e441fca60acf650da#egg=zulip==0.6.1_git&subdirectory=zulip +git+https://github.com/zulip/python-zulip-api.git@804501610b6a205334e71b4e441fca60acf650da#egg=zulip_bots==0.6.1+git&subdirectory=zulip_bots apns2==0.5.0 argon2-cffi==19.1.0 asn1crypto==0.24.0 # via cryptography @@ -113,7 +113,6 @@ stripe==2.21.0 tornado==4.5.3 traitlets==4.3.2 # via ipython twilio==6.29.2 -typing==3.6.6 typing_extensions==3.7.4 urllib3==1.25.3 # via requests uwsgi==2.0.17.1 diff --git a/version.py b/version.py index b15084e647..a841ec3974 100644 --- a/version.py +++ b/version.py @@ -26,4 +26,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2019/03/01/zulip-2-0-relea # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = '48.1' +PROVISION_VERSION = '49.0' diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py index 81088cb48c..8f7c1def5b 100644 --- a/zerver/openapi/python_examples.py +++ b/zerver/openapi/python_examples.py @@ -605,7 +605,7 @@ def send_message(client): def add_reaction(client, message_id): # type: (Client, int) -> None request = { - 'message_id': message_id, + 'message_id': str(message_id), 'emoji_name': 'joy', 'emoji_code': '1f602', 'emoji_type': 'unicode_emoji' @@ -618,7 +618,7 @@ def add_reaction(client, message_id): def remove_reaction(client, message_id): # type: (Client, int) -> None request = { - 'message_id': message_id, + 'message_id': str(message_id), 'emoji_name': 'joy', 'emoji_code': '1f602', 'reaction_type': 'unicode_emoji' diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index 08c05f7348..03e3c87f6e 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -44,7 +44,7 @@ from zerver.lib.redis_utils import get_redis_client from zerver.context_processors import common_context from zerver.lib.outgoing_webhook import do_rest_call, get_outgoing_webhook_service_handler from zerver.models import get_bot_services, RealmAuditLog -from zulip_bots.lib import extract_query_without_mention +from zulip_bots.lib import ExternalBotHandler, extract_query_without_mention from zerver.lib.bot_lib import EmbeddedBotHandler, get_bot_handler, EmbeddedBotQuitException from zerver.lib.exceptions import RateLimited from zerver.lib.export import export_realm_wrapper @@ -586,7 +586,7 @@ class EmbeddedBotWorker(QueueProcessingWorker): if event['trigger'] == 'mention': message['content'] = extract_query_without_mention( message=message, - client=self.get_bot_api_client(user_profile), + client=cast(ExternalBotHandler, self.get_bot_api_client(user_profile)), ) assert message['content'] is not None bot_handler.handle_message(