jxlpy icon indicating copy to clipboard operation
jxlpy copied to clipboard

Typing support

Open C0rn3j opened this issue 1 year ago • 0 comments

Could the function variable types and their return types be added?

All currently supported Python versions support typing.

It would make my LSP happy.

Here's an example of a fully typed class with functions:

# Importing annotations is a good idea - `from __future__ import annotations` - also supported everywhere, and stabilized in 3.14
from __future__ import annotations

# `TYPE_CHECKING` ensures the code does not actually get executed during runtime outside of a type checker
from typing import TYPE_CHECKING

if TYPE_CHECKING:
	from tauon.t_modules.t_main import GuiVar, PlayerCtl, Tauon, TDraw

class Launch:
	def __init__(self, tauon: Tauon, pctl: PlayerCtl, gui: GuiVar, ddt: TDraw) -> None:
		self.tauon = tauon
		self.pctl = pctl
		self.gui = gui
		self.ddt = ddt

	def render(self) -> None:
		pass

py.typed file also needs to be created in the module dir and classifier "Typing :: Typed", should be added to pyproject.toml, see https://typing.readthedocs.io/en/latest/spec/distributing.html#packaging-typed-libraries

C0rn3j avatar Nov 25 '24 12:11 C0rn3j