From 6904bd5885f92f9eb0ca15fd3a59c8f440457a64 Mon Sep 17 00:00:00 2001 From: Doug Hoskisson Date: Sun, 14 Jan 2024 06:31:13 -0800 Subject: [PATCH] Typing: improve kivy type stubs (#2681) --- .../{graphics.pyi => graphics/__init__.pyi} | 20 ++++--------------- typings/kivy/graphics/texture.pyi | 13 ++++++++++++ typings/kivy/uix/image.pyi | 9 +++++++++ 3 files changed, 26 insertions(+), 16 deletions(-) rename typings/kivy/{graphics.pyi => graphics/__init__.pyi} (54%) create mode 100644 typings/kivy/graphics/texture.pyi create mode 100644 typings/kivy/uix/image.pyi diff --git a/typings/kivy/graphics.pyi b/typings/kivy/graphics/__init__.pyi similarity index 54% rename from typings/kivy/graphics.pyi rename to typings/kivy/graphics/__init__.pyi index 19509106..a1a5bc02 100644 --- a/typings/kivy/graphics.pyi +++ b/typings/kivy/graphics/__init__.pyi @@ -1,24 +1,12 @@ -""" FillType_* is not a real kivy type - just something to fill unknown typing. """ - -from typing import Sequence - -FillType_Vec = Sequence[int] - - -class FillType_Drawable: - def __init__(self, *, pos: FillType_Vec = ..., size: FillType_Vec = ...) -> None: ... - - -class FillType_Texture(FillType_Drawable): - pass +from .texture import FillType_Drawable, FillType_Vec, Texture class FillType_Shape(FillType_Drawable): - texture: FillType_Texture + texture: Texture def __init__(self, *, - texture: FillType_Texture = ..., + texture: Texture = ..., pos: FillType_Vec = ..., size: FillType_Vec = ...) -> None: ... @@ -35,6 +23,6 @@ class Rectangle(FillType_Shape): def __init__(self, *, source: str = ..., - texture: FillType_Texture = ..., + texture: Texture = ..., pos: FillType_Vec = ..., size: FillType_Vec = ...) -> None: ... diff --git a/typings/kivy/graphics/texture.pyi b/typings/kivy/graphics/texture.pyi new file mode 100644 index 00000000..19e03aad --- /dev/null +++ b/typings/kivy/graphics/texture.pyi @@ -0,0 +1,13 @@ +""" FillType_* is not a real kivy type - just something to fill unknown typing. """ + +from typing import Sequence + +FillType_Vec = Sequence[int] + + +class FillType_Drawable: + def __init__(self, *, pos: FillType_Vec = ..., size: FillType_Vec = ...) -> None: ... + + +class Texture: + pass diff --git a/typings/kivy/uix/image.pyi b/typings/kivy/uix/image.pyi new file mode 100644 index 00000000..fa014bae --- /dev/null +++ b/typings/kivy/uix/image.pyi @@ -0,0 +1,9 @@ +import io + +from kivy.graphics.texture import Texture + + +class CoreImage: + texture: Texture + + def __init__(self, data: io.BytesIO, ext: str) -> None: ...