From 1c4eac67a0a355deb4d1cdf05df8832227635425 Mon Sep 17 00:00:00 2001 From: Ruan Comelli Date: Mon, 10 Feb 2025 13:25:11 -0300 Subject: [PATCH 1/4] fix(traceback): fix type-hints for `locals_max_{length|string}` The documentation of parameters `locals_max_length` and `locals_max_string` states that they can be `None`, in which case no maximum is applied. This commit fixes the corresponding type-hints to allow `None` by replacing `int` with `Optional[int]`. --- rich/traceback.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rich/traceback.py b/rich/traceback.py index 3bf5baa7b..19b51eb8a 100644 --- a/rich/traceback.py +++ b/rich/traceback.py @@ -53,8 +53,8 @@ def install( theme: Optional[str] = None, word_wrap: bool = False, show_locals: bool = False, - locals_max_length: int = LOCALS_MAX_LENGTH, - locals_max_string: int = LOCALS_MAX_STRING, + locals_max_length: Optional[int] = LOCALS_MAX_LENGTH, + locals_max_string: Optional[int] = LOCALS_MAX_STRING, locals_hide_dunder: bool = True, locals_hide_sunder: Optional[bool] = None, indent_guides: bool = True, @@ -252,8 +252,8 @@ def __init__( theme: Optional[str] = None, word_wrap: bool = False, show_locals: bool = False, - locals_max_length: int = LOCALS_MAX_LENGTH, - locals_max_string: int = LOCALS_MAX_STRING, + locals_max_length: Optional[int] = LOCALS_MAX_LENGTH, + locals_max_string: Optional[int] = LOCALS_MAX_STRING, locals_hide_dunder: bool = True, locals_hide_sunder: bool = False, indent_guides: bool = True, @@ -308,8 +308,8 @@ def from_exception( theme: Optional[str] = None, word_wrap: bool = False, show_locals: bool = False, - locals_max_length: int = LOCALS_MAX_LENGTH, - locals_max_string: int = LOCALS_MAX_STRING, + locals_max_length: Optional[int] = LOCALS_MAX_LENGTH, + locals_max_string: Optional[int] = LOCALS_MAX_STRING, locals_hide_dunder: bool = True, locals_hide_sunder: bool = False, indent_guides: bool = True, @@ -376,8 +376,8 @@ def extract( traceback: Optional[TracebackType], *, show_locals: bool = False, - locals_max_length: int = LOCALS_MAX_LENGTH, - locals_max_string: int = LOCALS_MAX_STRING, + locals_max_length: Optional[int] = LOCALS_MAX_LENGTH, + locals_max_string: Optional[int] = LOCALS_MAX_STRING, locals_hide_dunder: bool = True, locals_hide_sunder: bool = False, ) -> Trace: From 26b53b4b03489cdf174b87de0b5eb16c8ad75a5c Mon Sep 17 00:00:00 2001 From: Ruan Comelli Date: Mon, 10 Feb 2025 13:34:00 -0300 Subject: [PATCH 2/4] chore: add `ruancomelli` to list of contributors --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d8985ca13..ffd129930 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,6 +12,7 @@ The following people have contributed to the development of Rich: - [Dennis Brakhane](https://github.com/brakhane) - [Darren Burns](https://github.com/darrenburns) - [Ceyda Cinarel](https://github.com/cceyda) +- [Ruan Cardoso Comelli](https://github.com/ruancomelli) - [Jim Crist-Harif](https://github.com/jcrist) - [Ed Davis](https://github.com/davised) - [Pete Davison](https://github.com/pd93) From fd0acc0f325b643c23770912382c44579bf7942c Mon Sep 17 00:00:00 2001 From: Ruan Comelli Date: Mon, 10 Feb 2025 13:37:58 -0300 Subject: [PATCH 3/4] chore: add CHANGELOG entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7332fee..c8b96510e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [13.9.5] - 2025-02-10 + +### Fixed + +- Fixed type-hints for `locals_max_length` and `locals_max_string` in `Traceback` https://github.com/Textualize/rich/pull/3600 + ## [13.9.4] - 2024-11-01 ### Changed From 9d1b229dd5be1e2a97992e0ebea13b8bec8e3cd2 Mon Sep 17 00:00:00 2001 From: Ruan Comelli Date: Mon, 10 Feb 2025 13:39:11 -0300 Subject: [PATCH 4/4] chore: fix PR number in new changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8b96510e..ce81a4e31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fixed type-hints for `locals_max_length` and `locals_max_string` in `Traceback` https://github.com/Textualize/rich/pull/3600 +- Fixed type-hints for `locals_max_length` and `locals_max_string` in `Traceback` https://github.com/Textualize/rich/pull/3630 ## [13.9.4] - 2024-11-01