Skip to content

mypy telling Value of type "PdfObject" is not indexable #2140

Answered by pubpub-zz
rassie asked this question in Q&A
Discussion options

You must be logged in to vote

the annotation of the get([ ]) of a DictionaryObject such as trailer indicates the generic common type PdfObject, to prevent errors, you need to cast it to the adequate type):
root = cast(DictionaryObject,reader.trailer[TrailerKeys.ROOT])
you may neeed to add a global from pypdf.generic import *

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rassie
Comment options

Answer selected by rassie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants