Skip to content

Commit

Permalink
Move "# type: ignore" comments to fix mypy on Python < 3.8
Browse files Browse the repository at this point in the history
The placement of these comments got more flexible in 3.8 due to
python/mypy#1032

Satisfying older Python and fitting in flake8's 79-character line
limit was quite a challenge!
  • Loading branch information
0xabu committed Sep 3, 2021
1 parent da03afe commit dc24508
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pdfminer/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ def render(item: LTItem) -> None:
self.write('<text>%s</text>\n' % item.get_text())
elif isinstance(item, LTImage):
if self.imagewriter is not None:
name = self.imagewriter \
.export_image(item) # type: ignore[no-untyped-call]
name = (self.imagewriter. # type: ignore[no-untyped-call]
export_image(item))
self.write('<image src="%s" width="%d" height="%d" />\n' %
(enc(name), item.width, item.height))
else:
Expand Down
21 changes: 11 additions & 10 deletions pdfminer/pdfinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ def get_font(self, objid: Any, spec: Mapping[str, Any]) -> PDFFont:
subtype = 'Type1'
if subtype in ('Type1', 'MMType1'):
# Type1 Font
font = PDFType1Font(
self, spec) # type: ignore[no-untyped-call]
font = \
PDFType1Font(self, spec) # type: ignore[no-untyped-call]
elif subtype == 'TrueType':
# TrueType Font
font = PDFTrueTypeFont(
self, spec) # type: ignore[no-untyped-call]
font = \
PDFTrueTypeFont(self, spec) # type: ignore[no-untyped-call]
elif subtype == 'Type3':
# Type3 Font
font = PDFType3Font(
self, spec) # type: ignore[no-untyped-call]
font = \
PDFType3Font(self, spec) # type: ignore[no-untyped-call]
elif subtype in ('CIDFontType0', 'CIDFontType2'):
# CID Font
font = PDFCIDFont(self, spec) # type: ignore[no-untyped-call]
Expand All @@ -222,8 +222,9 @@ def get_font(self, objid: Any, spec: Mapping[str, Any]) -> PDFFont:
else:
if settings.STRICT:
raise PDFFontError('Invalid Font spec: %r' % spec)
font = PDFType1Font( # this is so wrong!
self, spec) # type: ignore[no-untyped-call]
# this is so wrong!
font = \
PDFType1Font(self, spec) # type: ignore[no-untyped-call]
if objid and self.caching:
self._cached_fonts[objid] = font
return font
Expand Down Expand Up @@ -892,8 +893,8 @@ def do_Do(self, xobjid: Any) -> None:
if subtype is LITERAL_FORM and 'BBox' in xobj:
interpreter = self.dup()
bbox: Rect = list_value(xobj['BBox']) # type: ignore[assignment]
matrix: Matrix = list_value(xobj.get(
'Matrix', MATRIX_IDENTITY)) # type: ignore[assignment]
matrix: Matrix = list_value( # type: ignore[assignment]
xobj.get('Matrix', MATRIX_IDENTITY))
# According to PDF reference 1.7 section 4.9.1, XObjects in
# earlier PDFs (prior to v1.2) use the page's Resources entry
# instead of having their own Resources entry.
Expand Down

0 comments on commit dc24508

Please sign in to comment.