Skip to content

Commit

Permalink
STY: Change int to float type hint (#2977)
Browse files Browse the repository at this point in the history
PEP 484 – Type Hints: when an argument is annotated as having type float, an argument of type int is acceptable.
Also remove two variables which are used immediately.
  • Loading branch information
j-t-1 authored Dec 2, 2024
1 parent 6d8a18a commit 402cc7f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3300,22 +3300,20 @@ def _set_page_label(
self._root_object[NameObject(CatalogDictionary.PAGE_LABELS)] = page_labels


def _pdf_objectify(obj: Union[Dict[str, Any], str, int, List[Any]]) -> PdfObject:
def _pdf_objectify(obj: Union[Dict[str, Any], str, float, List[Any]]) -> PdfObject:
if isinstance(obj, PdfObject):
return obj
if isinstance(obj, dict):
to_add = DictionaryObject()
for key, value in obj.items():
name_key = NameObject(key)
cast_value = _pdf_objectify(value)
to_add[name_key] = cast_value
to_add[NameObject(key)] = _pdf_objectify(value)
return to_add
elif isinstance(obj, str):
if obj.startswith("/"):
return NameObject(obj)
else:
return TextStringObject(obj)
elif isinstance(obj, (int, float)):
elif isinstance(obj, (float, int)):
return FloatObject(obj)
elif isinstance(obj, list):
return ArrayObject(_pdf_objectify(i) for i in obj)
Expand Down

0 comments on commit 402cc7f

Please sign in to comment.