Skip to content

Commit e3b37fa

Browse files
authored
STY: Remove unnecessary code around return statements (#3181)
Unnecessary assignment before a return statement. Unnecessary "else" after "return" statement.
1 parent a561b91 commit e3b37fa

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

pypdf/_reader.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,12 @@ def _info(self) -> Optional[DictionaryObject]:
254254
info = self.trailer.get(TK.INFO, None)
255255
if is_null_or_none(info):
256256
return None
257-
else:
258-
info = info.get_object()
259-
if not isinstance(info, DictionaryObject):
260-
raise PdfReadError(
261-
"Trailer not found or does not point to document information directory"
262-
)
263-
return info
257+
info = info.get_object()
258+
if not isinstance(info, DictionaryObject):
259+
raise PdfReadError(
260+
"Trailer not found or does not point to document information directory"
261+
)
262+
return info
264263

265264
@property
266265
def _ID(self) -> Optional[ArrayObject]:
@@ -325,8 +324,7 @@ def _get_page_number_by_indirect(
325324
else:
326325
idnum = indirect_reference.idnum
327326
assert self._page_id2num is not None, "hint for mypy"
328-
ret = self._page_id2num.get(idnum, None)
329-
return ret
327+
return self._page_id2num.get(idnum, None)
330328

331329
def _get_object_from_stream(
332330
self, indirect_reference: IndirectObject
@@ -923,10 +921,8 @@ def _read_xref(self, stream: StreamType) -> Optional[int]:
923921
)
924922
stream.seek(p, 0)
925923
if "/Prev" in new_trailer:
926-
startxref = new_trailer["/Prev"]
927-
return startxref
928-
else:
929-
return None
924+
return new_trailer["/Prev"]
925+
return None
930926

931927
def _read_xref_other_error(
932928
self, stream: StreamType, startxref: int
@@ -998,8 +994,7 @@ def get_entry(i: int) -> Union[int, Tuple[int, ...]]:
998994
# W array indicates...the default value shall be used
999995
if i == 0:
1000996
return 1 # First value defaults to 1
1001-
else:
1002-
return 0
997+
return 0
1003998

1004999
def used_before(num: int, generation: Union[int, Tuple[int, ...]]) -> bool:
10051000
# We move backwards through the xrefs, don't replace any.

0 commit comments

Comments
 (0)