From 0c14725f7c962cfc268771036fc3a5f32add5876 Mon Sep 17 00:00:00 2001 From: Diego OJ Date: Sun, 15 Nov 2026 12:35:03 -0300 Subject: [PATCH] Fix | ExitError: keep the per-instance exit code with newer click types click 8.5 declares ClickException.exit_code as a class variable, so mypy rejects setting it on the instance. click reads it from the instance when exiting, which is how each ExitError gets its own code: keep it, with an ignore that also passes on click 8.0 (unused-ignore). Unblocks the Dependabot runtime group (#365). Co-Authored-By: Claude Opus 5.5 --- leverage/_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/leverage/_utils.py b/leverage/_utils.py index 40baab1..0ce544a 100644 --- a/leverage/_utils.py +++ b/leverage/_utils.py @@ -69,7 +69,10 @@ class ExitError(ClickException): """ def __init__(self, exit_code: int, error_description: str): - self.exit_code = exit_code + # Newer click releases declare exit_code as a class variable (1 for every ClickException), but click reads + # it from the instance when exiting: setting it here gives each error its own code. `unused-ignore` keeps + # mypy quiet on the click releases that don't declare it so. + self.exit_code = exit_code # type: ignore[misc, unused-ignore] super(ExitError, self).__init__(message=error_description) def show(self):