This repository was archived by the owner on Aug 21, 2025. It is now read-only.
Commit 513ae3a
authored
feat: improve typing definitions, introduce mypy in CI (#338)
* feat: do not supress callback exceptions raised from calling callbacks
* fix: add explicit clauses for ConnectionClosedOK in send and heartbeat
* fix: change import order
* fix: apply ruff format
* feat: introduce flake.nix leveraging pyproject.nix
introduce flake.nix configuration leveraging the already existing
information in pyproject.toml, by using pyproject.nix to parse it and
generate the correct derivation. this way, any updates to
pyproject.toml should automatically be reflected in the flake
configuration, with low additional maintaining overhead required.
the only time when this may come as a problem is due to dependabot
constantly upgrading the packages to versions that do not exist yet in
nixpkgs. it may be required to force dependabot to also update the
nixpkgs version declared in the flake for it to not also break (or at
least to upgrade less often)
* chore: make `flake.nix` aware of dev dependencies, including ruff and pre-commit
by adding `dependency-groups`, `pyproject.nix` can now parse the
dependency groups and add these to the project, by passing `groups =
["dev"]` when calling the renderer.
special care was needed in order to expose `ruff` and `pre-commit` to
the toplevel of the environment. by default, it will treat them as
python dependencies and hide them in the python wrapper. by using
`groupBy`, we split the dependency list in "python" dependencies and
top level ones, such that they can be exposed.
sadly, these toplevel packages are not exposed in `python.pkgs` so we
must manually override them in a case by case basis.
* chore: refactor `dependencies-for`
* feat: add nix develop CI job
ensure that `nix develop` works on CI
* fix: change job name to be more compatible with the other actions
* feat: setup infra and run `python -m pytest` to run tests in nix setup action
do not rely on poetry to run tests, we'd like to not rely on it from
within the nix environment
* fix: do not rely on `npx` as its not on nix develop
use manual `supabase start` command instead
* fix: add `--command` typo
* chore: change name of nix develop command part
* feat: add coverage information and upload it to coveralls
* chore: run nix setup tests in both ubuntu and macos
* chore: undo macos latest as it apparently does not work
for some reason, `supabase start` does not seem to work on
`macos-latest` host in CI
* chore: switch from pylsp + mypy to pyright (basepyright)
it seems that pyright is better and faster than mypy in most if not
all cases, and the only reason I wasn't using it before is because it
was not working with eglot's default config.
* feat: add `basedpyright` to `pyproject.toml` instead of flake.nix only
this makes it available to all users, preparing for including it into
the standard CI later on
* fix: change back to python-lsp-server with pylsp-mypy
* chore: improve type definitions files to make mypy happy
there's still a lot of issues that I intend to improve upon. this is
just an initial set of changes to ensure that `mypy` doesn't
complain. we should further strengthen the mypy checking
rules (currently there are a lot of `Any`s in the code) as the code improves.
* chore: add mypy to CI as a step
* fix: run mypy through poetry
* fix: check for phx_ref_prev before calling del
* fix: use `python -m mypy` instead of `mypy` directly
* fix: run type check after `make run_tests` so that `poetry install` is ran
* fix: `StrEnum` does not exist in python 3.9
* fix: remove `phx_ref` from presence dict
* fix: add deprecation warning for calling send with dicts
* fix: fix config payload, improve more types
* fix: make typing definitions compatible with python 3.9
also enforce that mypy uses python 3.9 only rules.
* fix: import annotations for 3.9 to not complain about type error
* fix: move mypy to Makefile `run_tests`, run it before actual tests
* format: apply ruff reformating
* fix: try explicitly annotating `Callback` as a `TypeAlias`
* fix: change `dict` to `Dict` type due to 3.9
* fix: finally, import annotations to stop runtime from breaking
* format: apply ruff format one last time
* format: reorder import order in test_connection
* format: trim whitespace1 parent a8b063f commit 513ae3a
File tree
12 files changed
+339
-158
lines changed- .github/workflows
- realtime
- _async
- tests
12 files changed
+339
-158
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
65 | | - | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | | - | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | | - | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
111 | 116 | | |
112 | 117 | | |
113 | 118 | | |
114 | | - | |
115 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| |||
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
180 | 190 | | |
181 | 191 | | |
182 | 192 | | |
183 | | - | |
| 193 | + | |
184 | 194 | | |
185 | | - | |
186 | | - | |
187 | | - | |
| 195 | + | |
188 | 196 | | |
189 | 197 | | |
190 | 198 | | |
| |||
253 | 261 | | |
254 | 262 | | |
255 | 263 | | |
256 | | - | |
| 264 | + | |
257 | 265 | | |
258 | 266 | | |
259 | 267 | | |
| |||
263 | 271 | | |
264 | 272 | | |
265 | 273 | | |
266 | | - | |
| 274 | + | |
267 | 275 | | |
268 | | - | |
| 276 | + | |
269 | 277 | | |
270 | 278 | | |
271 | 279 | | |
| |||
310 | 318 | | |
311 | 319 | | |
312 | 320 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
320 | 326 | | |
| 327 | + | |
| 328 | + | |
321 | 329 | | |
322 | 330 | | |
323 | 331 | | |
324 | 332 | | |
325 | 333 | | |
326 | 334 | | |
327 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
328 | 339 | | |
329 | 340 | | |
330 | 341 | | |
| |||
411 | 422 | | |
412 | 423 | | |
413 | 424 | | |
414 | | - | |
| 425 | + | |
415 | 426 | | |
416 | 427 | | |
417 | 428 | | |
| |||
508 | 519 | | |
509 | 520 | | |
510 | 521 | | |
511 | | - | |
| 522 | + | |
512 | 523 | | |
513 | 524 | | |
514 | 525 | | |
| |||
562 | 573 | | |
563 | 574 | | |
564 | 575 | | |
565 | | - | |
| 576 | + | |
566 | 577 | | |
567 | 578 | | |
568 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | | - | |
103 | | - | |
| 102 | + | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
239 | | - | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
294 | 296 | | |
295 | 297 | | |
296 | 298 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | 299 | | |
306 | 300 | | |
307 | 301 | | |
| |||
325 | 319 | | |
326 | 320 | | |
327 | 321 | | |
328 | | - | |
| 322 | + | |
329 | 323 | | |
330 | 324 | | |
331 | 325 | | |
| |||
340 | 334 | | |
341 | 335 | | |
342 | 336 | | |
343 | | - | |
344 | | - | |
345 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| |||
0 commit comments