Anders Kaseorg
9ea290d5ae
python: Reformat with Ruff formatter.
...
https://docs.astral.sh/ruff/formatter/
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 570f3dd447
)
2024-03-07 15:07:12 -08:00
Charlie Marsh
13bc9a5867
ruff: Upgrade configuration for Ruff v0.2.0.
...
(cherry picked from commit c8e77b6cac
)
2024-03-07 15:07:12 -08:00
Anders Kaseorg
f8aac58a6a
docs: Update Ruff badge and links.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 15:51:46 -07:00
Anders Kaseorg
a50eb2e809
mypy: Enable new error explicit-override.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-12 12:28:41 -07:00
Anders Kaseorg
b4a2e71b6b
mypy: Enable new errors redundant-self, truthy-iterable.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-12 12:28:41 -07:00
Anders Kaseorg
6988622fe8
ruff: Enable B023 Function definition does not bind loop variable.
...
Python’s loop scoping is misdesigned, resulting in a very common
gotcha for functions that close over loop variables [1]. The general
problem is so bad that even the Go developers plan to break
compatibility in order to fix the same design mistake in their
language [2].
Enable the Ruff rule function-uses-loop-variable (B023) [3], which
conservatively prohibits functions from binding loop variables at all.
[1] https://docs.python-guide.org/writing/gotchas/#late-binding-closures
[2] https://go.dev/s/loopvar-design
[3] https://beta.ruff.rs/docs/rules/function-uses-loop-variable/
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-11 18:03:45 -07:00
Anders Kaseorg
cf4791264c
python: Replace functools.partial with type-safe returns.curry.partial.
...
The type annotation for functools.partial uses unchecked Any for all
the function parameters (both early and late). returns.curry.partial
uses a mypy plugin to check the parameters safely.
https://returns.readthedocs.io/en/latest/pages/curry.html
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-11 18:03:45 -07:00
Anders Kaseorg
22e8b641e1
mypy: Remove exemption for aioapns.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-09 10:10:24 -07:00
Anders Kaseorg
ddba558f1d
mypy: Remove no_implicit_reexport override.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-08 16:46:44 -07:00
Anders Kaseorg
5fe0cb3054
pyproject: Delete trailing whitespace.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-09-08 10:13:47 -07:00
Zixuan James Li
7da4e73d57
requirements: Add pydantic and configure mypy plugin.
...
Along with pydantic we add annotated_types for Annotated utils that can
be used for more specific validation constraints.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-09-08 08:20:17 -07:00
Anders Kaseorg
ca40e60469
ruff: Enable PERF rules.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-07 17:23:55 -07:00
Anders Kaseorg
55aa29bef4
ruff: Fix FLY002 Consider f"…" instead of string join.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-07 17:12:41 -07:00
Anders Kaseorg
733083c65d
ruff: Collapse short multi-line import statements.
...
isort did this by default, though it’s unclear whether that was
intended; see https://github.com/astral-sh/ruff/issues/4153 .
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-08-02 17:41:41 -07:00
Anders Kaseorg
ff409342e1
runtornado: Fix COM818 Trailing comma on bare tuple prohibited.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-31 13:35:04 -07:00
Anders Kaseorg
29bdaaf5b5
requirements: Upgrade Python requirements.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-19 16:14:59 -07:00
Anders Kaseorg
ff6cf54716
pyproject: Remove mypy exemption for coverage.
...
coverage added type annotations in 7.2.0.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-19 16:14:59 -07:00
Anders Kaseorg
03b3c8522d
requirements: Upgrade Python requirements.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-25 21:20:33 -07:00
Anders Kaseorg
9db3451333
Remove statsd support.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-25 19:58:16 -07:00
Alex Vandiver
e536a14b61
report_error: Remove API endpoint for client error reporting.
2023-04-13 14:59:58 -07:00
Anders Kaseorg
b3a185103d
ruff: Enable new lints INT, PYI.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-12 17:32:38 -07:00
Anders Kaseorg
bb2c0ad3bf
ruff: Enable Django rules.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-12 17:32:38 -07:00
Anders Kaseorg
a881918a05
requirements: Upgrade Python requirements.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-03 22:39:21 -07:00
Anders Kaseorg
144166cdc4
mypy: Remove exclusions for unused cssutils and premailer packages.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-04-03 16:52:51 -07:00
Anders Kaseorg
087660a87e
requirements: Upgrade Python requirements.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-05 14:46:28 -08:00
Anders Kaseorg
5aaa36b8fc
ruff: Enable logging format rules.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:36:20 -08:00
Anders Kaseorg
61f672c652
ruff: Enable raise rules.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-04 16:34:55 -08:00
Anders Kaseorg
81a7c7502f
requirements: Upgrade Python requirements.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-03 16:36:54 -08:00
Alex Vandiver
cc9b028312
uploads: Set X-Accel-Redirect manually, without using django-sendfile2.
...
The `django-sendfile2` module unfortunately only supports a single
`SENDFILE` root path -- an invariant which subsequent commits need to
break. Especially as Zulip only runs with a single webserver, and
thus sendfile backend, the functionality is simple to inline.
It is worth noting that the following headers from the initial Django
response are _preserved_, if present, and sent unmodified to the
client; all other headers are overridden by those supplied by the
internal redirect[^1]:
- Content-Type
- Content-Disposition
- Accept-Ranges
- Set-Cookie
- Cache-Control
- Expires
As such, we explicitly unset the Content-type header to allow nginx to
set it from the static file, but set Content-Disposition and
Cache-Control as we want them to be.
[^1]: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/
2023-01-09 18:23:58 -05:00
Anders Kaseorg
778275575e
ruff: Ignore RUF002 for consistency.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-04 23:06:04 -08:00
Anders Kaseorg
2afdb46095
ruff: Enable new lints DTZ, ISC, PIE, PLW, Q, S, SIM.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-04 16:25:07 -08:00
Anders Kaseorg
730b93c338
mypy: Link issues for type annotations in cairosvg, coverage, ldap.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-02 22:22:57 -08:00
Anders Kaseorg
c3475e83ec
mypy: Link issue for missing py.typed in aioapns.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-04 22:11:24 -08:00
Anders Kaseorg
4898fdb89d
ruff: Enable some new errors.
...
PGH001 forbids eval().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-04 22:11:24 -08:00
Anders Kaseorg
e3d57c9586
ruff: Fix B006 Do not use mutable data structures for argument defaults.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-04 22:11:24 -08:00
Anders Kaseorg
7ccc24d9fe
requirements: Upgrade Python requirements.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-04 22:11:24 -08:00
Anders Kaseorg
c850a006d9
emoji: Import modules relative to ZULIP_PATH.
...
Newer mypy is less confused this way.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-04 22:11:24 -08:00
Anders Kaseorg
73c4da7974
ruff: Fix N818 exception name should be named with an Error suffix.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-17 16:52:00 -08:00
Anders Kaseorg
9a8a2bd345
ruff: Enable import sorting, replacing isort.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
06e64e5713
ruff: Enable sys.version errors.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
1b016bef73
ruff: Enable naming errors.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
cc01c68aa9
ruff: Enable annotations errors.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
3442bf2843
requirements: Upgrade Ruff.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
c2cbc57bc4
ruff: Specify all selected errors.
...
extend-select may be removed upstream.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-07 22:17:40 -08:00
Anders Kaseorg
66393640a8
ruff: Configure target-version.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-07 22:17:40 -08:00
Anders Kaseorg
d494181127
ruff: Enable more errors.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
adffad384c
lint: Replace pycodestyle and pyflakes with ruff.
...
https://github.com/charliermarsh/ruff
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
133c8b16ed
requirements: Upgrade openapi-core.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-10-07 10:03:51 -07:00
PIG208
df18bbbd48
requirements: Add django-stubs and configure plugin.
...
Note that django_stubs_ext is required to be placed within common.in
because we need the monkeypatched types in runtime; django-stubs
itself is for type checking only.
In the future, we would like to pin to a release instead of a git
revision, but several patches we've contributed upstream have not
appeared in a release yet.
We also remove the type annotation for RealmAuditLog.event_last_message_id
here instead of earlier because type checking fails otherwise.
Fixes #11560 .
2022-10-05 16:15:56 -07:00
Zixuan James Li
b3f27b1843
mypy: Enable local_partial_types.
...
dmypy is innately incompatible with `local_partial_types` being
`False` as it uses fined-grained incremental mode for caching.
We need to enable `local_partial_types` for mypy as well so that the two
will behave the same way.
This requires us to add additional type annotation in certain siuations
but that's fine.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-06 17:33:13 -07:00