From 8aca2787c3f983bce892e6c3655f0ffbe1fb22fd Mon Sep 17 00:00:00 2001 From: rajpreetcodes Date: Tue, 13 Oct 2026 09:32:46 +0530 Subject: [PATCH] fix: resolve deprecated contextmanager return annotation and un-ignore rule Annotating @contextmanager functions as -> Iterator is deprecated in Python 3.15 typeshed stubs; updated to -> Generator[None]. Un-ignores rules.deprecated in pyproject.toml. Contributes to #15187. --- dynamic_programming/matrix_chain_multiplication.py | 4 ++-- pyproject.toml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dynamic_programming/matrix_chain_multiplication.py b/dynamic_programming/matrix_chain_multiplication.py index 4c0c771f9092..9d7877a36bfb 100644 --- a/dynamic_programming/matrix_chain_multiplication.py +++ b/dynamic_programming/matrix_chain_multiplication.py @@ -45,7 +45,7 @@ ``26000`` """ -from collections.abc import Iterator +from collections.abc import Generator from contextlib import contextmanager from functools import cache from sys import maxsize @@ -128,7 +128,7 @@ def a(i: int, j: int) -> int: @contextmanager -def elapsed_time(msg: str) -> Iterator: +def elapsed_time(msg: str) -> Generator[None]: # print(f"Starting: {msg}") from time import perf_counter_ns diff --git a/pyproject.toml b/pyproject.toml index 52bd60b9d3aa..932f64f2e00a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -317,7 +317,6 @@ skip = """\ # free-threaded 3.15t test venv would otherwise leave several stubs unresolved. environment.python-version = "3.15" rules.call-non-callable = "ignore" -rules.deprecated = "ignore" rules.invalid-argument-type = "ignore" rules.invalid-return-type = "ignore" rules.no-matching-overload = "ignore"