Skip to content

Commit be5e282

Browse files
authored
fix(typing): Make sure mypy types ffi and lib as Any to avoid typing errors (#6239)
1 parent 40bc3d2 commit be5e282

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

py/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# FFI
22
sentry_relay/_lowlevel*
3+
!sentry_relay/_lowlevel.pyi
34

45
# Wheels
56
dist

py/sentry_relay/ _lowlevel.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Type stub for the cffi-generated native module `sentry_relay._lowlevel`.
2+
#
3+
# At runtime `_lowlevel.py` does `lib = ffi.dlopen(...)`, so `lib`/`ffi` are
4+
# populated dynamically from the Rust; their attributes cannot be known statically.
5+
# Without this stub, mypy types `lib` as cffi's generic `_cffi_backend.Lib`,
6+
# which declares none of the `relay_*` functions and so generates errors.
7+
# Here, we type them as Any to avoid these errors.
8+
from typing import Any
9+
10+
ffi: Any
11+
lib: Any

0 commit comments

Comments
 (0)