Skip to content

Commit f224e44

Browse files
committed
Bench(fix[lgtm]): Let mypy type-check the scripts without the otel group
why: CI runs `mypy .`, which reaches `scripts/`, but installs only the default and dev groups -- the `otel` group is deliberately excluded so the ordinary gates stay lean. Every OpenTelemetry, pyroscope, and rampa import was therefore unresolvable in CI while resolving fine on a machine that had the group installed. what: - Allow those three imports to be missing, so the scripts type-check in both environments rather than only the one the developer happens to have - Relax subclassing-Any and untyped-decorator for the two modules that build on them, scoped per module: an inline ignore would itself be unused wherever the group is installed
1 parent 297eb0b commit f224e44

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,30 @@ files = [
186186
"tests",
187187
]
188188

189+
# The observability scripts import third-party packages from the optional
190+
# `otel` group, which CI does not install so the ordinary gates stay lean.
191+
# `mypy .` still reaches those scripts, so their imports must be allowed to
192+
# be absent. `rampa` ships no stubs either way.
193+
[[tool.mypy.overrides]]
194+
module = [
195+
"opentelemetry.*",
196+
"pyroscope",
197+
"rampa",
198+
]
199+
ignore_missing_imports = true
200+
201+
# Those same packages ship no stubs, so anything derived from them is `Any`:
202+
# a SpanProcessor subclass and rampa's scenario decorators. Relaxing the two
203+
# strictness flags here is scoped to these scripts and, unlike an inline
204+
# ignore, stays correct whether or not the optional group is installed.
205+
[[tool.mypy.overrides]]
206+
module = [
207+
"telemetry",
208+
"load_tmux",
209+
]
210+
disallow_subclassing_any = false
211+
disallow_untyped_decorators = false
212+
189213

190214
[tool.ty.environment]
191215
python-version = "3.10"

scripts/otel_smoke.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _profile_lane(lane: str, *, enabled: bool) -> t.Iterator[None]:
154154
if not enabled:
155155
yield
156156
return
157-
import pyroscope # type: ignore[import-untyped]
157+
import pyroscope
158158

159159
with pyroscope.tag_wrapper({"tmux_lane": lane}):
160160
yield

0 commit comments

Comments
 (0)