Skip to content

Commit df4bf21

Browse files
Apply suggestions from code review
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent 907a10e commit df4bf21

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Lib/configparser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,14 +1071,15 @@ def __repr__(self):
10711071
"interpolation": type(self._interpolation).__name__,
10721072
}
10731073
init_params = {k: v for k, v in init_params.items() if v is not None}
1074+
sections_count = len(self._sections)
10741075
state_summary = {
10751076
"loaded_sources": self._loaded_sources,
1076-
"sections_count": len(self._sections),
1077-
"sections": list(self._sections.keys())[:5], # Limit to 5 section names for readability
1077+
"sections_count": sections_count,
1078+
"sections": list(self._sections)[:5], # limit to 5 section names for readability
10781079
}
10791080

1080-
if len(self._sections) > 5:
1081-
state_summary["sections_truncated"] = f"...and {len(self._sections) - 5} more"
1081+
if sections_count > 5:
1082+
state_summary["sections_truncated"] = f"...and {sections_count - 5} more"
10821083

10831084
return (f"<{self.__class__.__name__}("
10841085
f"params={init_params}, "
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Implement :meth:`~object.__str__` and :meth:`~object.__repr__`
2-
for :class:`configparser.RawConfigParser` objects
2+
for :class:`configparser.RawConfigParser` objects.

0 commit comments

Comments
 (0)