Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing support #33

Open
C0rn3j opened this issue Nov 25, 2024 · 0 comments
Open

Typing support #33

C0rn3j opened this issue Nov 25, 2024 · 0 comments

Comments

@C0rn3j
Copy link

C0rn3j commented Nov 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant