Commit graph

687 commits

Author SHA1 Message Date
Anders Kaseorg
2f581293d9 ruff: Fix FLY002 Consider f-string instead of string join.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:09:17 -07:00
Anders Kaseorg
fcd4fe330d ruff: Fix UP031 Use format specifiers instead of percent format.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:04:41 -07:00
Anders Kaseorg
ddccf0eda3 ruff: Fix UP032 Use f-string instead of format call.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:01:58 -07:00
Anders Kaseorg
a49add3d02 lint: Replace Black with Ruff.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 19:08:40 -07:00
Anders Kaseorg
01a27a3a1b lint: Replace Flake8 with Ruff.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 18:58:49 -07:00
Anders Kaseorg
5c299c7eff google_search: Add missing type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 17:47:53 -07:00
Anders Kaseorg
602ebb18fe connect_four: Add missing type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 17:40:41 -07:00
Anders Kaseorg
6cb1d5f775 mypy: Enable explicit-override error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 14:03:17 -07:00
Anders Kaseorg
43654b9cf2 mypy: Enable ignore-without-code error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 13:43:42 -07:00
Anders Kaseorg
95b33b83b5 mypy: Enable redundant-expr error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 13:41:24 -07:00
Anders Kaseorg
e747d3b712 mypy: Enable no_implicit_reexport.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 13:38:57 -07:00
Anders Kaseorg
3b4867ad46 simple_lib: Add type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:59:41 -07:00
Anders Kaseorg
f55d5ea555 Mark Python 3.11 supported.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:00:47 -07:00
Anders Kaseorg
183bb933b4 test_run: Patch importlib.import_module last.
importlib.import_module is now used in the implementation of
unittest.mock.patch.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 15:58:50 -07:00
Anders Kaseorg
98e23bdfd4 Remove Python 3.7 support.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 13:23:37 -07:00
Anders Kaseorg
a9607dfdf9 Convert type comments to Python ≥ 3.6 variable annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-18 01:04:47 -07:00
Anders Kaseorg
8abca34a05 youtube: Fix for HTTPError stub change.
https://github.com/python/typeshed/pull/10875

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-17 19:03:47 -07:00
Zixuan James Li
1b8f1d6e51 lint: Pin black to avoid inconsistent formatting.
This also runs black to reformat the affected files, which had been
causing failures because of upstream updates.

Ideally, we need a more sophisticated toolchain for managing the
versions of the dependencies instead of just requirements.txt. This
should be due in a possible future cleanup.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Anders Kaseorg
c94da617ed Remove Python 3.6; add Python 3.10.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-24 12:04:59 -08:00
Anders Kaseorg
d26416a1e7 Release version 0.8.2.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-15 17:44:12 -07:00
Anders Kaseorg
05d591a906 Remove legacy distutils support.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-02-28 10:35:58 -08:00
Anders Kaseorg
113f9cb885 converter: Reformat with Black 22.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-02-09 18:51:30 -08:00
Eeshan Garg
74d716289b tools: Delete the release-packages script.
This script has been outdated for a long time now and has been
obsoleted by some recent changes in how packages should be built
and distributed. In general, the release process is now too
complicated to automate, so we are better off just making the
release manually.
2022-01-05 08:11:58 +05:30
neiljp (Neil Pilgrim)
e0f3bd4143 bots: Migrate source file for zulip-bot-shell to similar name. 2021-11-21 21:06:40 -08:00
neiljp (Neil Pilgrim)
cca1b7d679 mypy: Add types to terminal.py. 2021-11-21 21:06:40 -08:00
neiljp (Neil Pilgrim)
4982adcb17 bots: Migrate script name from zulip-terminal to zulip-bot-shell.
This change is intended to reduce confusion between zulip-bot-shell
(test bots interactively without a server) and the zulip/zulip-terminal
project and its associated command (zulip-term).
2021-11-19 11:48:37 -08:00
Eeshan Garg
76b8aacf5c zulip_bots: Remove include_package_data=True argument from setup().
According to the `setuptools` docs, once `include_package_data=True`
is passed to `setup()`, it will only include package data specified
in `MANIFEST.in`, and will ignore the `package_data` argument passed
to `setup()`. Thus, the `py.typed` file was not included in our
latest PyPI release 0.8.1.

A quick way to fix this is to remove the `include_package_data=True`
argument and to let our explicit `package_data` argument values
govern what data is included in the release.

See https://github.com/pypa/setuptools/issues/1461 for background.
2021-10-27 11:15:01 -07:00
Eeshan Garg
fec8cc50c4 pypi: Release version 0.8.1. 2021-10-19 18:03:52 -04:00
Anders Kaseorg
d32d442c44 Upgrade mypy to 0.910.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 20:19:05 -07:00
Anders Kaseorg
189cf48573 chessbot: Upgrade python-chess to chess.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 19:01:58 -07:00
Anders Kaseorg
1e6513136a tests: Set encoding for mock HTTP responses.
Fixes warnings like ‘UserWarning: Trying to detect encoding from a
tiny portion of (2) byte(s).’

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 18:03:52 -07:00
Anders Kaseorg
e8bb65b188 tests: Replace deprecated assertRaisesRegexp with assertRaisesRegex.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 17:20:53 -07:00
Anders Kaseorg
b02b84204a merels: Add missing __init__.py, and really fix the tests.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 16:05:34 -07:00
PIG208
66434d07cf bots: Indicate source of bot (from source/module/registry) upon startup.
Amend tests to include new parameter.
2021-07-29 11:08:33 -07:00
PIG208
4bc0c607c1 bots: Find external packaged bots via 'zulip_bots.registry' entry_point.
Now we will be able to execute `zulip-run-bot` with the `-r` argument
to search for and run bots from the `zulip_bots.registry` entry_point.

Each entry point should have the name correspond to the bot name,
and have the value be the bot module. E.g, an Python package for a
bot called "packaged_bot" should have an `entry_points` setup like
the following:

setup(
    ...
    entry_points={
        "zulip_bot.registry":[
            "packaged_bot=packaged_bot.packaged_bot"
        ]
    }
    ...
)

whose file structure may look like this:

packaged_bot/
├───packaged_bot/
|   ├───packaged_bot.py  # The bot module
|   ├───test_packaged_bot.py
|   ├───packaged_bot.conf
|   └───doc.md
└───setup.py  # Register the entry points here

Add test case.
2021-07-29 11:08:31 -07:00
anehls93
71d488e560 zulip_bots: Add doc.md for game_of_fifteen bot.
Finishes #513.
2021-06-28 12:40:20 -02:30
PIG208
9ce7c52a10 pyupgrade: Reformat with --py36-plus.
This includes mainly fixes of string literals using f-strings or
.format(...), as well as unpacking of list comprehensions.
2021-06-02 18:45:57 -07:00
PIG208
e27ac0ddbe pyupgrade: Replace Text with str.
We uses `pyupgrade --py3-plus` to automatically replace all occurence
of `Text`. But manual fix is required to remove the unused imports. Note
that with this configuration pyupgrade also convert string literals to
.format(...) style, which is manually not included in the commit as well.
2021-06-02 18:45:57 -07:00
PIG208
6f3f9bf7e4 black: Reformat without skipping string normalization. 2021-06-02 18:45:57 -07:00
PIG208
fba21bb00d black: Reformat skipping string normalization. 2021-06-02 18:45:57 -07:00
PIG208
5580c68ae5 isort: Reformat using isort. 2021-06-02 18:45:57 -07:00
PIG208
37e2596124 zulip_bots: Add docstrings and comments for TerminalBotHandler. 2021-05-27 23:52:07 -07:00
PIG208
d949f2024f zulip_bots: Rename SimpleMessageServer to MockMessageServer.
Given that the purpose of this message server is solely for testing,
we rename it for clarity.
2021-05-27 23:52:07 -07:00
PIG208
bd27631dd1 zulip-bots: Yield cache storage instead bot storage.
Fixes the bug that the context manager doesn't actually manage the
storage.
2021-05-27 23:49:41 -07:00
PIG208
b8389b78c1 zulip-bots: Use context manager for incrementor. 2021-05-24 14:30:19 -07:00
PIG208
86fa9f5e35 zulip-bots: Implement context manager.
The context manager is implemented based on a newly added storage called
CachedStorage. It is a bufferred storage that doesn't sync with the
database until it's flushed. With CachedStorage, we can implement the
context manager easily by loading all the data on __enter__ and just
flush all the modified (dirty) data on __exit__. This approach can help
the user minimize the number of round-trips to the server almost
invisibly (despite the fact that they need to use it with "with").

Fixes: #679
2021-05-24 14:30:19 -07:00
PIG208
e0723c1db4 zulip-bots: Move protocols for context manager. 2021-05-24 14:30:19 -07:00
PIG208
b04f5f9753 terminal: Implement react for TerminalBotHandler.
Fixes: #686
2021-05-24 14:22:29 -07:00
PIG208
0b35ed0a93 terminal: Extract message server from the handler.
This makes the user and the bot to share the message server when
sending messages. As a result, the message id can be shared. And history
messages sent by the user will be stored as well.
2021-05-24 14:22:29 -07:00
PIG208
fb77f4bad4 terminal: Apply BotHandler for TerminalBotHandler. 2021-05-24 14:22:29 -07:00