event checkers: Replace data_types.py with pydantic.

This commit completely eliminates the home-grown
data_types.py system for checking types.

Now, in our unit tests and schema checkers, we use
pydantic types to check the shape of the event
objects that are either in our JSON fixtures or
that get captured by test_events.py.

The code in event_types.py was completely
code-generated from the legacy version of
event_schema.py, so there shouldn't be any
manual errors in how I ported the types over.
(The code generation was non-trivial, though,
as I had to account for changes from
snake_case to CamelCase and deal with some
other anomalies.)
This commit is contained in:
Steve Howell
2025-01-01 17:08:17 +00:00
committed by Tim Abbott
parent 934f584257
commit 5fd24bc9a2
6 changed files with 1439 additions and 1942 deletions

View File

@@ -12,6 +12,8 @@ FILES_WITH_LEGACY_SUBJECT = {
# This basically requires a big DB migration:
"zerver/lib/topic.py",
"zerver/lib/topic_sqlalchemy.py",
# This is tied to legacy events.
"zerver/lib/event_types.py",
# This is for backward compatibility.
"zerver/tests/test_legacy_subject.py",
# Other migration-related changes require extreme care.