From 4bff0a214f8b6a1d8208c085b2792b1376f60446 Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Thu, 26 Dec 2024 08:09:20 +0000 Subject: [PATCH 1/2] STY: Use generator expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PEP 289 – Generator Expressions. --- pypdf/_doc_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypdf/_doc_common.py b/pypdf/_doc_common.py index e8b7a0665..6757a6211 100644 --- a/pypdf/_doc_common.py +++ b/pypdf/_doc_common.py @@ -715,7 +715,7 @@ def indexed_key(k: str, fields: Dict[Any, Any]) -> str: return ( k + "." - + str(sum([1 for kk in fields if kk.startswith(k + ".")]) + 2) + + str(sum(1 for kk in fields if kk.startswith(k + ".")) + 2) ) # Retrieve document form fields From e636789666c21fdf12f4013482c2c5f9cfa9e4e4 Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Thu, 26 Dec 2024 08:12:12 +0000 Subject: [PATCH 2/2] STY: Use generator expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PEP 289 – Generator Expressions. --- pypdf/_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypdf/_reader.py b/pypdf/_reader.py index b04ea1761..16c24db09 100644 --- a/pypdf/_reader.py +++ b/pypdf/_reader.py @@ -1181,7 +1181,7 @@ def add_form_topname(self, name: str) -> Optional[DictionaryObject]: interim[NameObject("/Kids")] = acroform[NameObject("/Fields")] self.cache_indirect_object( 0, - max([i for (g, i) in self.resolved_objects if g == 0]) + 1, + max(i for (g, i) in self.resolved_objects if g == 0) + 1, interim, ) arr = ArrayObject()