mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Fix Any subclassing in fpdf2 (#9536)
This commit is contained in:
@@ -6,6 +6,9 @@ fpdf.fpdf.FPDF.output
|
||||
fpdf.FPDF.set_creation_date
|
||||
fpdf.fpdf.FPDF.set_creation_date
|
||||
|
||||
# fonttools shims since we can't import it
|
||||
fpdf._fonttools_shims
|
||||
|
||||
# Checking the following function crashes stubtest 0.991, but seems to be
|
||||
# fixed in later versions.
|
||||
fpdf.FPDF.set_encryption
|
||||
|
||||
52
stubs/fpdf2/fpdf/_fonttools_shims.pyi
Normal file
52
stubs/fpdf2/fpdf/_fonttools_shims.pyi
Normal file
@@ -0,0 +1,52 @@
|
||||
# from fontTools.misc.loggingTools
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections.abc import Mapping
|
||||
from logging import Logger
|
||||
from typing import Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# from fonttools.ttLib.ttGlyphSet
|
||||
class _TTGlyph(Protocol):
|
||||
def __init__(self, glyphSet: _TTGlyphSet, glyphName: str) -> None: ...
|
||||
def draw(self, pen) -> None: ...
|
||||
def drawPoints(self, pen) -> None: ...
|
||||
|
||||
_TTGlyphSet: TypeAlias = Mapping[str, _TTGlyph] # Simplified for our needs
|
||||
|
||||
# from fontTools.misc.loggingTools
|
||||
|
||||
class LogMixin:
|
||||
@property
|
||||
def log(self) -> Logger: ...
|
||||
|
||||
# from fontTools.pens.basePen
|
||||
class AbstractPen:
|
||||
@abstractmethod
|
||||
def moveTo(self, pt: tuple[float, float]) -> None: ...
|
||||
@abstractmethod
|
||||
def lineTo(self, pt: tuple[float, float]) -> None: ...
|
||||
@abstractmethod
|
||||
def curveTo(self, *points: tuple[float, float]) -> None: ...
|
||||
@abstractmethod
|
||||
def qCurveTo(self, *points: tuple[float, float]) -> None: ...
|
||||
def closePath(self) -> None: ...
|
||||
def endPath(self) -> None: ...
|
||||
@abstractmethod
|
||||
def addComponent(self, glyphName: str, transformation: tuple[float, float, float, float, float, float]) -> None: ...
|
||||
|
||||
class LoggingPen(LogMixin, AbstractPen, metaclass=ABCMeta): ...
|
||||
|
||||
class DecomposingPen(LoggingPen, metaclass=ABCMeta):
|
||||
skipMissingComponents: bool
|
||||
glyphSet: _TTGlyphSet | None
|
||||
def __init__(self, glyphSet: _TTGlyphSet | None) -> None: ...
|
||||
def addComponent(self, glyphName: str, transformation: tuple[float, float, float, float, float, float]) -> None: ...
|
||||
|
||||
class BasePen(DecomposingPen):
|
||||
def __init__(self, glyphSet: _TTGlyphSet | None = ...) -> None: ...
|
||||
def closePath(self) -> None: ...
|
||||
def endPath(self) -> None: ...
|
||||
def moveTo(self, pt: tuple[float, float]) -> None: ...
|
||||
def lineTo(self, pt: tuple[float, float]) -> None: ...
|
||||
def curveTo(self, *points: tuple[float, float]) -> None: ...
|
||||
def qCurveTo(self, *points: tuple[float, float]) -> None: ...
|
||||
@@ -1,9 +1,10 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Callable
|
||||
from re import Pattern
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_BasePen: TypeAlias = Incomplete # actually fontTools.pens.basePen.BasePen
|
||||
from fpdf.drawing import PaintedPath
|
||||
|
||||
from ._fonttools_shims import BasePen, _TTGlyphSet
|
||||
|
||||
__pdoc__: dict[str, bool]
|
||||
|
||||
@@ -56,14 +57,14 @@ class ShapeBuilder:
|
||||
|
||||
def convert_transforms(tfstr): ...
|
||||
|
||||
class PathPen(_BasePen):
|
||||
pdf_path: Incomplete
|
||||
class PathPen(BasePen):
|
||||
pdf_path: PaintedPath
|
||||
last_was_line_to: bool
|
||||
first_is_move: bool | None
|
||||
def __init__(self, pdf_path, *args, **kwargs): ...
|
||||
def __init__(self, pdf_path: PaintedPath, glyphSet: _TTGlyphSet | None = ...): ...
|
||||
def arcTo(self, rx, ry, rotation, arc, sweep, end) -> None: ...
|
||||
|
||||
def svg_path_converter(pdf_path, svg_path) -> None: ...
|
||||
def svg_path_converter(pdf_path: PaintedPath, svg_path: str) -> None: ...
|
||||
|
||||
class SVGObject:
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user