Boy I wished, that customtkinter would be correctly typed :/

This commit is contained in:
Christoph Stahl 2023-12-18 19:44:21 +01:00
parent cb00e62143
commit 159a08f824
8 changed files with 9 additions and 71 deletions

View file

@ -1,10 +1,12 @@
image: python:3-alpine
variables:
MYPYPATH: "stubs/"
mypy:
stage: test
script:
- pip install mypy --quiet
- mypy --install-types
- pip install mypy types-Pillow types-PyYAML --quiet
- mypy syng --strict
ruff:

View file

@ -1,66 +0,0 @@
from tkinter import Tk
from typing import Any, Callable, Optional
from PIL.Image import Image
class CTk(Tk):
def __init__(self, parent: Optional[Tk] = None, className: str = "Tk") -> None:
pass
def pack(
self,
expand: bool = False,
fill: str = "",
side: str = "",
padx: int = 0,
pady: int = 0,
ipadx: int = 0,
ipady: int = 0,
anchor: str = "",
) -> None: ...
def grid(
self, column: int, row: int, padx: int = 0, pady: int = 0, sticky: str = ""
) -> None: ...
def configure(self, **kwargs: Any) -> None: ...
class CTkToplevel(CTk): ...
class CTkFrame(CTk): ...
class CTkImage:
def __init__(self, light_image: Image, size: tuple[int, int]) -> None: ...
class CTkTabview(CTk):
def __init__(self, parent: Tk, width: int, height: int) -> None: ...
def add(self, name: str) -> None: ...
def set(self, name: str) -> None: ...
def tab(self, name: str) -> CTkFrame: ...
class CTkOptionMenu(CTk):
def __init__(self, parent: Tk, values: list[str]) -> None: ...
def set(self, value: str) -> None: ...
def get(self) -> str: ...
class CTkCheckBox(CTk):
def __init__(self, parent: Tk, text: str, onvalue: Any, offvalue: Any) -> None: ...
def select(self) -> None: ...
def deselect(self) -> None: ...
def get(self) -> Any: ...
class CTkLabel(CTk):
def __init__(self, parent: Tk, text: str, justify: str = "") -> None: ...
class CTkTextbox(CTk):
def __init__(self, parent: Tk, wrap: str = "none", height: int = 1) -> None: ...
def get(self, start: str, end: str) -> str: ...
def delete(self, start: str, end: str) -> None: ...
def insert(self, start: str, value: str) -> None: ...
class CTkScrollableFrame(CTk): ...
class CTkButton(CTk):
def __init__(
self,
parent: Tk,
text: str,
command: Callable[..., None],
width: Optional[int] = None,
) -> None: ...

View file

@ -56,6 +56,8 @@ module = [
"qrcode",
"engineio",
"tkcalendar",
"customtkinter",
"aiohttp",
"tktimepicker"
]
ignore_missing_imports = true

View file

@ -24,7 +24,7 @@ from .sources import available_sources
from .server import main as server_main
class DateAndTimePickerWindow(customtkinter.CTkToplevel):
class DateAndTimePickerWindow(customtkinter.CTkToplevel): # type: ignore
def __init__(
self,
parent: customtkinter.CTkFrame | customtkinter.CTkScrollableFrame,
@ -76,7 +76,7 @@ class DateAndTimePickerWindow(customtkinter.CTkToplevel):
self.destroy()
class OptionFrame(customtkinter.CTkScrollableFrame):
class OptionFrame(customtkinter.CTkScrollableFrame): # type:ignore
def add_option_label(self, text: str) -> None:
customtkinter.CTkLabel(self, text=text, justify="left").grid(
column=0, row=self.number_of_options, padx=5, pady=5, sticky="ne"
@ -296,7 +296,7 @@ class GeneralConfig(OptionFrame):
return config
class SyngGui(customtkinter.CTk):
class SyngGui(customtkinter.CTk): # type:ignore
def on_close(self) -> None:
if self.syng_server is not None:
self.syng_server.kill()