From feb031ba86d3f22e41cfbbda13f17c039359f1e6 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Mon, 6 Sep 2021 15:18:26 -0700 Subject: [PATCH] add missing None return type to all __init__ methods --- pdfminer/arcfour.py | 2 +- pdfminer/ccitt.py | 6 +++--- pdfminer/cmapdb.py | 12 ++++++------ pdfminer/converter.py | 12 ++++++------ pdfminer/image.py | 5 +++-- pdfminer/layout.py | 34 +++++++++++++++++----------------- pdfminer/lzw.py | 2 +- pdfminer/pdfcolor.py | 2 +- pdfminer/pdfdevice.py | 4 ++-- pdfminer/pdfdocument.py | 4 ++-- pdfminer/pdffont.py | 20 +++++++++++--------- pdfminer/pdfinterp.py | 6 +++--- pdfminer/pdfpage.py | 3 ++- pdfminer/pdfparser.py | 4 ++-- pdfminer/pdftypes.py | 3 ++- pdfminer/psparser.py | 10 +++++----- pdfminer/utils.py | 5 +++-- 17 files changed, 70 insertions(+), 64 deletions(-) diff --git a/pdfminer/arcfour.py b/pdfminer/arcfour.py index 5967a1af..dd2697ce 100644 --- a/pdfminer/arcfour.py +++ b/pdfminer/arcfour.py @@ -10,7 +10,7 @@ class Arcfour: - def __init__(self, key: Sequence[int]): + def __init__(self, key: Sequence[int]) -> None: # because Py3 range is not indexable s = [i for i in range(256)] j = 0 diff --git a/pdfminer/ccitt.py b/pdfminer/ccitt.py index c2b8bb40..0a9a78ca 100644 --- a/pdfminer/ccitt.py +++ b/pdfminer/ccitt.py @@ -337,7 +337,7 @@ class ByteSkip(Exception): _color: int - def __init__(self, width: int, bytealign: bool = False): + def __init__(self, width: int, bytealign: bool = False) -> None: BitParser.__init__(self) self.width = width self.bytealign = bytealign @@ -541,7 +541,7 @@ def _do_uncompressed(self, bits: str) -> None: class CCITTFaxDecoder(CCITTG4Parser): def __init__(self, width: int, bytealign: bool = False, - reversed: bool = False): + reversed: bool = False) -> None: CCITTG4Parser.__init__(self, width, bytealign=bytealign) self.reversed = reversed self._buf = b'' @@ -582,7 +582,7 @@ def main(argv: List[str]) -> None: return class Parser(CCITTG4Parser): - def __init__(self, width: int, bytealign: bool = False): + def __init__(self, width: int, bytealign: bool = False) -> None: import pygame # type: ignore[import] CCITTG4Parser.__init__(self, width, bytealign=bytealign) self.img = pygame.Surface((self.width, 1000)) diff --git a/pdfminer/cmapdb.py b/pdfminer/cmapdb.py index 76a4e394..853d877a 100644 --- a/pdfminer/cmapdb.py +++ b/pdfminer/cmapdb.py @@ -41,7 +41,7 @@ class CMapBase: debug = 0 - def __init__(self, **kwargs: object): + def __init__(self, **kwargs: object) -> None: self.attrs: MutableMapping[str, object] = kwargs.copy() return @@ -68,7 +68,7 @@ def decode(self, code: bytes) -> Iterable[int]: class CMap(CMapBase): - def __init__(self, **kwargs: Union[str, int]): + def __init__(self, **kwargs: Union[str, int]) -> None: CMapBase.__init__(self, **kwargs) self.code2cid: Dict[int, object] = {} return @@ -142,7 +142,7 @@ def decode(self, code: bytes) -> Tuple[int, ...]: class UnicodeMap(CMapBase): - def __init__(self, **kwargs: Union[str, int]): + def __init__(self, **kwargs: Union[str, int]) -> None: CMapBase.__init__(self, **kwargs) self.cid2unichr: Dict[int, str] = {} return @@ -200,7 +200,7 @@ def add_cid2unichr(self, cid: int, code: Union[PSLiteral, bytes, int] class PyCMap(CMap): - def __init__(self, name: str, module: Any): + def __init__(self, name: str, module: Any) -> None: super().__init__(CMapName=name) self.code2cid = module.CODE2CID if module.IS_VERTICAL: @@ -210,7 +210,7 @@ def __init__(self, name: str, module: Any): class PyUnicodeMap(UnicodeMap): - def __init__(self, name: str, module: Any, vertical: bool): + def __init__(self, name: str, module: Any, vertical: bool) -> None: super().__init__(CMapName=name) if vertical: self.cid2unichr = module.CID2UNICHR_V @@ -278,7 +278,7 @@ def get_unicode_map(cls, name: str, vertical: bool = False) -> UnicodeMap: class CMapParser(PSStackParser[PSKeyword]): - def __init__(self, cmap: CMapBase, fp: BinaryIO): + def __init__(self, cmap: CMapBase, fp: BinaryIO) -> None: PSStackParser.__init__(self, fp) self.cmap = cmap # some ToUnicode maps don't have "begincmap" keyword. diff --git a/pdfminer/converter.py b/pdfminer/converter.py index 793078c0..27ec0190 100644 --- a/pdfminer/converter.py +++ b/pdfminer/converter.py @@ -43,7 +43,7 @@ class PDFLayoutAnalyzer(PDFTextDevice): ctm: Matrix def __init__(self, rsrcmgr: PDFResourceManager, pageno: int = 1, - laparams: Optional[LAParams] = None): + laparams: Optional[LAParams] = None) -> None: PDFTextDevice.__init__(self, rsrcmgr) self.pageno = pageno self.laparams = laparams @@ -167,7 +167,7 @@ class PDFPageAggregator(PDFLayoutAnalyzer): def __init__(self, rsrcmgr: PDFResourceManager, pageno: int = 1, - laparams: Optional[LAParams] = None): + laparams: Optional[LAParams] = None) -> None: PDFLayoutAnalyzer.__init__(self, rsrcmgr, pageno=pageno, laparams=laparams) self.result: Optional[LTPage] = None @@ -192,7 +192,7 @@ def __init__(self, outfp: IOType, codec: str = 'utf-8', pageno: int = 1, - laparams: Optional[LAParams] = None): + laparams: Optional[LAParams] = None) -> None: PDFLayoutAnalyzer.__init__(self, rsrcmgr, pageno=pageno, laparams=laparams) self.outfp: IOType = outfp @@ -223,7 +223,7 @@ def __init__(self, pageno: int = 1, laparams: Optional[LAParams] = None, showpageno: bool = False, - imagewriter: Optional[ImageWriter] = None): + imagewriter: Optional[ImageWriter] = None) -> None: super().__init__(rsrcmgr, outfp, codec=codec, pageno=pageno, laparams=laparams) self.showpageno = showpageno @@ -299,7 +299,7 @@ def __init__(self, imagewriter: Optional[ImageWriter] = None, debug: int = 0, rect_colors: Optional[Dict[str, str]] = None, - text_colors: Optional[Dict[str, str]] = None): + text_colors: Optional[Dict[str, str]] = None) -> None: PDFConverter.__init__(self, rsrcmgr, outfp, codec=codec, pageno=pageno, laparams=laparams) @@ -530,7 +530,7 @@ def __init__(self, pageno: int = 1, laparams: Optional[LAParams] = None, imagewriter: Optional[ImageWriter] = None, - stripcontrol: bool = False): + stripcontrol: bool = False) -> None: PDFConverter.__init__(self, rsrcmgr, outfp, codec=codec, pageno=pageno, laparams=laparams) diff --git a/pdfminer/image.py b/pdfminer/image.py index 55fcafb0..45f1de68 100644 --- a/pdfminer/image.py +++ b/pdfminer/image.py @@ -17,7 +17,8 @@ def align32(x: int) -> int: class BMPWriter: - def __init__(self, fp: BinaryIO, bits: int, width: int, height: int): + def __init__(self, fp: BinaryIO, bits: int, width: int, height: int + ) -> None: self.fp = fp self.bits = bits self.width = width @@ -65,7 +66,7 @@ class ImageWriter: Supports various image types: JPEG, JBIG2 and bitmaps """ - def __init__(self, outdir: str): + def __init__(self, outdir: str) -> None: self.outdir = outdir if not os.path.exists(self.outdir): os.makedirs(self.outdir) diff --git a/pdfminer/layout.py b/pdfminer/layout.py index 1cbdf142..618fcddd 100644 --- a/pdfminer/layout.py +++ b/pdfminer/layout.py @@ -26,7 +26,7 @@ class IndexAssigner: - def __init__(self, index: int = 0): + def __init__(self, index: int = 0) -> None: self.index = index return @@ -75,7 +75,7 @@ def __init__(self, word_margin: float = 0.1, boxes_flow: Optional[float] = 0.5, detect_vertical: bool = False, - all_texts: bool = False): + all_texts: bool = False) -> None: self.line_overlap = line_overlap self.char_margin = char_margin self.line_margin = line_margin @@ -127,7 +127,7 @@ def get_text(self) -> str: class LTComponent(LTItem): """Object with a bounding box""" - def __init__(self, bbox: Rect): + def __init__(self, bbox: Rect) -> None: LTItem.__init__(self) self.set_bbox(bbox) return @@ -206,7 +206,7 @@ class LTCurve(LTComponent): def __init__(self, linewidth: float, pts: List[Point], stroke: bool = False, fill: bool = False, evenodd: bool = False, stroking_color: Optional[Color] = None, - non_stroking_color: Optional[Color] = None): + non_stroking_color: Optional[Color] = None) -> None: LTComponent.__init__(self, get_bound(pts)) self.pts = pts self.linewidth = linewidth @@ -230,7 +230,7 @@ class LTLine(LTCurve): def __init__(self, linewidth: float, p0: Point, p1: Point, stroke: bool = False, fill: bool = False, evenodd: bool = False, stroking_color: Optional[Color] = None, - non_stroking_color: Optional[Color] = None): + non_stroking_color: Optional[Color] = None) -> None: LTCurve.__init__(self, linewidth, [p0, p1], stroke, fill, evenodd, stroking_color, non_stroking_color) return @@ -245,7 +245,7 @@ class LTRect(LTCurve): def __init__(self, linewidth: float, bbox: Rect, stroke: bool = False, fill: bool = False, evenodd: bool = False, stroking_color: Optional[Color] = None, - non_stroking_color: Optional[Color] = None): + non_stroking_color: Optional[Color] = None) -> None: (x0, y0, x1, y1) = bbox LTCurve.__init__(self, linewidth, [(x0, y0), (x1, y0), (x1, y1), (x0, y1)], stroke, @@ -259,7 +259,7 @@ class LTImage(LTComponent): Embedded images can be in JPEG, Bitmap or JBIG2. """ - def __init__(self, name: str, stream: PDFStream, bbox: Rect): + def __init__(self, name: str, stream: PDFStream, bbox: Rect) -> None: LTComponent.__init__(self, bbox) self.name = name self.stream = stream @@ -286,7 +286,7 @@ class LTAnno(LTItem, LTText): according to the relationship between two characters (e.g. a space). """ - def __init__(self, text: str): + def __init__(self, text: str) -> None: self._text = text return @@ -300,7 +300,7 @@ class LTChar(LTComponent, LTText): def __init__(self, matrix: Matrix, font: PDFFont, fontsize: float, scaling: float, rise: float, text: str, textwidth: float, textdisp: Union[float, Tuple[Optional[float], float]], - ncs: PDFColorSpace, graphicstate: PDFGraphicState): + ncs: PDFColorSpace, graphicstate: PDFGraphicState) -> None: LTText.__init__(self) self._text = text self.matrix = matrix @@ -360,7 +360,7 @@ def is_compatible(self, obj: object) -> bool: class LTContainer(LTComponent, Generic[LTItemT]): """Object that can be extended and analyzed""" - def __init__(self, bbox: Rect): + def __init__(self, bbox: Rect) -> None: LTComponent.__init__(self, bbox) self._objs: List[LTItemT] = [] return @@ -421,7 +421,7 @@ class LTTextLine(LTTextContainer[TextLineElement]): the text's writing mode. """ - def __init__(self, word_margin: float): + def __init__(self, word_margin: float) -> None: super().__init__() self.word_margin = word_margin return @@ -442,7 +442,7 @@ def find_neighbors(self, plane: Plane[LTComponentT], ratio: float class LTTextLineHorizontal(LTTextLine): - def __init__(self, word_margin: float): + def __init__(self, word_margin: float) -> None: LTTextLine.__init__(self, word_margin) self._x1: float = +INF return @@ -505,7 +505,7 @@ def _is_same_height_as(self, other: LTComponent, tolerance: float = 0 class LTTextLineVertical(LTTextLine): - def __init__(self, word_margin: float): + def __init__(self, word_margin: float) -> None: LTTextLine.__init__(self, word_margin) self._y0: float = -INF return @@ -612,7 +612,7 @@ def get_writing_mode(self) -> str: class LTTextGroup(LTTextContainer[TextGroupElement]): - def __init__(self, objs: Iterable[TextGroupElement]): + def __init__(self, objs: Iterable[TextGroupElement]) -> None: super().__init__() self.extend(objs) return @@ -643,7 +643,7 @@ def analyze(self, laparams: LAParams) -> None: class LTLayoutContainer(LTContainer[LTComponent]): - def __init__(self, bbox: Rect): + def __init__(self, bbox: Rect) -> None: LTContainer.__init__(self, bbox) self.groups: Optional[List[LTTextGroup]] = None return @@ -886,7 +886,7 @@ class LTFigure(LTLayoutContainer): recursively. """ - def __init__(self, name: str, bbox: Rect, matrix: Matrix): + def __init__(self, name: str, bbox: Rect, matrix: Matrix) -> None: self.name = name self.matrix = matrix (x, y, w, h) = bbox @@ -914,7 +914,7 @@ class LTPage(LTLayoutContainer): LTCurve and LTLine. """ - def __init__(self, pageid: int, bbox: Rect, rotate: float = 0): + def __init__(self, pageid: int, bbox: Rect, rotate: float = 0) -> None: LTLayoutContainer.__init__(self, bbox) self.pageid = pageid self.rotate = rotate diff --git a/pdfminer/lzw.py b/pdfminer/lzw.py index 4e5e6df9..31c085ed 100644 --- a/pdfminer/lzw.py +++ b/pdfminer/lzw.py @@ -12,7 +12,7 @@ class CorruptDataError(Exception): class LZWDecoder: - def __init__(self, fp: BinaryIO): + def __init__(self, fp: BinaryIO) -> None: self.fp = fp self.buff = 0 self.bpos = 8 diff --git a/pdfminer/pdfcolor.py b/pdfminer/pdfcolor.py index d53b8641..df685ed1 100644 --- a/pdfminer/pdfcolor.py +++ b/pdfminer/pdfcolor.py @@ -10,7 +10,7 @@ class PDFColorSpace: - def __init__(self, name: str, ncomponents: int): + def __init__(self, name: str, ncomponents: int) -> None: self.name = name self.ncomponents = ncomponents return diff --git a/pdfminer/pdfdevice.py b/pdfminer/pdfdevice.py index f14861a2..c5b998b6 100644 --- a/pdfminer/pdfdevice.py +++ b/pdfminer/pdfdevice.py @@ -23,7 +23,7 @@ class PDFDevice: """Translate the output of PDFPageInterpreter to the output that is needed """ - def __init__(self, rsrcmgr: "PDFResourceManager"): + def __init__(self, rsrcmgr: "PDFResourceManager") -> None: self.rsrcmgr = rsrcmgr self.ctm: Optional[Matrix] = None return @@ -168,7 +168,7 @@ def render_char(self, matrix: Matrix, font: PDFFont, fontsize: float, class TagExtractor(PDFDevice): def __init__(self, rsrcmgr: "PDFResourceManager", outfp: BinaryIO, - codec: str = 'utf-8'): + codec: str = 'utf-8') -> None: PDFDevice.__init__(self, rsrcmgr) self.outfp = outfp self.codec = codec diff --git a/pdfminer/pdfdocument.py b/pdfminer/pdfdocument.py index 177bde26..c96d5bfc 100644 --- a/pdfminer/pdfdocument.py +++ b/pdfminer/pdfdocument.py @@ -305,7 +305,7 @@ class PDFStandardSecurityHandler: supported_revisions: Tuple[int, ...] = (2, 3) def __init__(self, docid: Sequence[bytes], param: Dict[str, Any], - password: str = ''): + password: str = '') -> None: self.docid = docid self.param = param self.password = password @@ -576,7 +576,7 @@ class PDFDocument: } def __init__(self, parser: PDFParser, password: str = '', - caching: bool = True, fallback: bool = True): + caching: bool = True, fallback: bool = True) -> None: "Set the document to use a given PDFParser object." self.caching = caching self.xrefs: List[PDFBaseXRef] = [] diff --git a/pdfminer/pdffont.py b/pdfminer/pdffont.py index 582fc2ce..b9f8f500 100644 --- a/pdfminer/pdffont.py +++ b/pdfminer/pdffont.py @@ -104,7 +104,7 @@ class Type1FontHeaderParser(PSStackParser[int]): KEYWORD_READONLY = KWD(b'readonly') KEYWORD_FOR = KWD(b'for') - def __init__(self, data: BinaryIO): + def __init__(self, data: BinaryIO) -> None: PSStackParser.__init__(self, data) self._cid2unicode: Dict[int, str] = {} return @@ -285,7 +285,7 @@ class CFFFont: class INDEX: - def __init__(self, fp: BinaryIO): + def __init__(self, fp: BinaryIO) -> None: self.fp = fp self.offsets: List[int] = [] (count, offsize) = struct.unpack('>HB', self.fp.read(3)) @@ -308,7 +308,7 @@ def __getitem__(self, i: int) -> bytes: def __iter__(self) -> Iterator[bytes]: return iter(self[i] for i in range(len(self))) - def __init__(self, name: str, fp: BinaryIO): + def __init__(self, name: str, fp: BinaryIO) -> None: self.name = name self.fp = fp # Header @@ -402,7 +402,7 @@ class TrueTypeFont: class CMapNotFound(Exception): pass - def __init__(self, name: str, fp: BinaryIO): + def __init__(self, name: str, fp: BinaryIO) -> None: self.name = name self.fp = fp self.tables: Dict[bytes, Tuple[int, int]] = {} @@ -526,7 +526,7 @@ class PDFUnicodeNotDefined(PDFFontError): class PDFFont: def __init__(self, descriptor: Mapping[str, Any], widths: FontWidthDict, - default_width: Optional[float] = None): + default_width: Optional[float] = None) -> None: self.descriptor = descriptor self.widths: FontWidthDict = resolve_all(widths) self.fontname = resolve1(descriptor.get('FontName', 'unknown')) @@ -612,7 +612,7 @@ def to_unichr(self, cid: int) -> str: class PDFSimpleFont(PDFFont): def __init__(self, descriptor: Mapping[str, Any], widths: FontWidthDict, - spec: Mapping[str, Any]): + spec: Mapping[str, Any]) -> None: # Font encoding is specified either by a name of # built-in encoding or a dictionary that describes # the differences. @@ -649,7 +649,8 @@ def to_unichr(self, cid: int) -> str: class PDFType1Font(PDFSimpleFont): - def __init__(self, rsrcmgr: "PDFResourceManager", spec: Mapping[str, Any]): + def __init__(self, rsrcmgr: "PDFResourceManager", spec: Mapping[str, Any] + ) -> None: try: self.basefont = literal_name(spec['BaseFont']) except KeyError: @@ -689,7 +690,8 @@ def __repr__(self) -> str: class PDFType3Font(PDFSimpleFont): - def __init__(self, rsrcmgr: "PDFResourceManager", spec: Mapping[str, Any]): + def __init__(self, rsrcmgr: "PDFResourceManager", spec: Mapping[str, Any] + ) -> None: firstchar = int_value(spec.get('FirstChar', 0)) # lastchar = int_value(spec.get('LastChar', 0)) width_list = list_value(spec.get('Widths', [0]*256)) @@ -713,7 +715,7 @@ class PDFCIDFont(PDFFont): default_disp: Union[float, Tuple[Optional[float], float]] def __init__(self, rsrcmgr: "PDFResourceManager", spec: Mapping[str, Any], - strict: bool = settings.STRICT): + strict: bool = settings.STRICT) -> None: try: self.basefont = literal_name(spec['BaseFont']) except KeyError: diff --git a/pdfminer/pdfinterp.py b/pdfminer/pdfinterp.py index 324a76c6..4056a1e4 100644 --- a/pdfminer/pdfinterp.py +++ b/pdfminer/pdfinterp.py @@ -157,7 +157,7 @@ class PDFResourceManager: allocated multiple times. """ - def __init__(self, caching: bool = True): + def __init__(self, caching: bool = True) -> None: self.caching = caching self._cached_fonts: Dict[object, PDFFont] = {} return @@ -227,7 +227,7 @@ def get_font(self, objid: object, spec: Mapping[str, object]) -> PDFFont: class PDFContentParser(PSStackParser[Union[PSKeyword, PDFStream]]): - def __init__(self, streams: Sequence[object]): + def __init__(self, streams: Sequence[object]) -> None: self.streams = streams self.istream = 0 # PSStackParser.__init__(fp=None) is safe only because we've overloaded @@ -337,7 +337,7 @@ class PDFPageInterpreter: Reference: PDF Reference, Appendix A, Operator Summary """ - def __init__(self, rsrcmgr: PDFResourceManager, device: PDFDevice): + def __init__(self, rsrcmgr: PDFResourceManager, device: PDFDevice) -> None: self.rsrcmgr = rsrcmgr self.device = device return diff --git a/pdfminer/pdfpage.py b/pdfminer/pdfpage.py index a584b392..9d08bc5a 100644 --- a/pdfminer/pdfpage.py +++ b/pdfminer/pdfpage.py @@ -42,7 +42,8 @@ class PDFPage: beads: a chain that represents natural reading order. """ - def __init__(self, doc: PDFDocument, pageid: object, attrs: object): + def __init__(self, doc: PDFDocument, pageid: object, attrs: object + ) -> None: """Initialize a page object. doc: a PDFDocument object. diff --git a/pdfminer/pdfparser.py b/pdfminer/pdfparser.py index f7cfeb17..18ad9ebd 100644 --- a/pdfminer/pdfparser.py +++ b/pdfminer/pdfparser.py @@ -41,7 +41,7 @@ class PDFParser(PSStackParser[Union[PSKeyword, PDFStream, PDFObjRef, None]]): """ - def __init__(self, fp: BinaryIO): + def __init__(self, fp: BinaryIO) -> None: PSStackParser.__init__(self, fp) self.doc: Optional["PDFDocument"] = None self.fallback = False @@ -146,7 +146,7 @@ class PDFStreamParser(PDFParser): indirect references to other objects in the same document. """ - def __init__(self, data: bytes): + def __init__(self, data: bytes) -> None: PDFParser.__init__(self, BytesIO(data)) return diff --git a/pdfminer/pdftypes.py b/pdfminer/pdftypes.py index 0e91b1ab..8a8baf86 100644 --- a/pdfminer/pdftypes.py +++ b/pdfminer/pdftypes.py @@ -74,7 +74,8 @@ class PDFNotImplementedError(PDFException): class PDFObjRef(PDFObject): - def __init__(self, doc: Optional["PDFDocument"], objid: int, _: object): + def __init__(self, doc: Optional["PDFDocument"], objid: int, _: object + ) -> None: if objid == 0: if settings.STRICT: raise PDFValueError('PDF object id cannot be 0.') diff --git a/pdfminer/psparser.py b/pdfminer/psparser.py index dd6dbddc..4562257b 100644 --- a/pdfminer/psparser.py +++ b/pdfminer/psparser.py @@ -54,7 +54,7 @@ class PSLiteral(PSObject): NameType = Union[str, bytes] - def __init__(self, name: NameType): + def __init__(self, name: NameType) -> None: self.name = name def __repr__(self) -> str: @@ -74,7 +74,7 @@ class PSKeyword(PSObject): Always use PSKeywordTable.intern(). """ - def __init__(self, name: bytes): + def __init__(self, name: bytes) -> None: self.name = name return @@ -92,7 +92,7 @@ class PSSymbolTable(Generic[_SymbolT]): Interned objects can be checked its identity with "is" operator. """ - def __init__(self, klass: Type[_SymbolT]): + def __init__(self, klass: Type[_SymbolT]) -> None: self.dict: Dict[PSLiteral.NameType, _SymbolT] = {} self.klass: Type[_SymbolT] = klass return @@ -179,7 +179,7 @@ class PSBaseParser: """ BUFSIZ = 4096 - def __init__(self, fp: BinaryIO): + def __init__(self, fp: BinaryIO) -> None: self.fp = fp self.seek(0) return @@ -521,7 +521,7 @@ def nexttoken(self) -> Tuple[int, PSBaseParserToken]: class PSStackParser(PSBaseParser, Generic[ExtraT]): - def __init__(self, fp: BinaryIO): + def __init__(self, fp: BinaryIO) -> None: PSBaseParser.__init__(self, fp) self.reset() return diff --git a/pdfminer/utils.py b/pdfminer/utils.py index 7b0af8dd..3f21857a 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -30,7 +30,8 @@ class open_filename(object): (str or pathlib.PurePath type is supported) and closes it on exit, (just like `open`), but does nothing for file-like objects. """ - def __init__(self, filename: FileOrName, *args: Any, **kwargs: Any): + def __init__(self, filename: FileOrName, *args: Any, **kwargs: Any + ) -> None: if isinstance(filename, pathlib.PurePath): filename = str(filename) if isinstance(filename, str): @@ -437,7 +438,7 @@ class Plane(Generic[LTComponentT]): which is sorted by its x or y coordinate. """ - def __init__(self, bbox: Rect, gridsize: int = 50): + def __init__(self, bbox: Rect, gridsize: int = 50) -> None: self._seq: List[LTComponentT] = [] # preserve the object order. self._objs: Set[LTComponentT] = set() self._grid: Dict[Point, List[LTComponentT]] = {}