Skip to content

Commit b7f7375

Browse files
authored
STY: Convert once to Path.pathlib (#3817)
Replaces unnecessary conversion to a str and then a Path.pathlib.
1 parent e0cb0b1 commit b7f7375

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

pypdf/_writer.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,11 @@ def _get_clone_from(
268268
):
269269
return clone_from
270270
cloning = True
271-
if isinstance(fileobj, (str, Path)) and (
272-
not Path(str(fileobj)).exists()
273-
or Path(str(fileobj)).stat().st_size == 0
274-
):
275-
cloning = False
276-
if isinstance(fileobj, (IOBase, BytesIO)):
271+
if isinstance(fileobj, (str, Path)):
272+
fileobj_path = Path(fileobj)
273+
if not fileobj_path.exists() or fileobj_path.stat().st_size == 0:
274+
cloning = False
275+
elif isinstance(fileobj, (IOBase, BytesIO)):
277276
t = fileobj.tell()
278277
if fileobj.seek(0, 2) == 0:
279278
cloning = False

0 commit comments

Comments
 (0)