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 updates #2252

Merged
merged 14 commits into from
Jun 11, 2024
1 change: 1 addition & 0 deletions changes/2252.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The typing for Toga's API surface was updated to be more precise.
7 changes: 5 additions & 2 deletions core/src/toga/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import annotations

import warnings
from pathlib import Path

from .app import App, DocumentApp, DocumentMainWindow, MainWindow

Expand Down Expand Up @@ -49,7 +52,7 @@ class NotImplementedWarning(RuntimeWarning):
# single argument (the warning message). Use a factory method to avoid reproducing
# the message format and the warn invocation.
@classmethod
def warn(self, platform, feature):
def warn(cls, platform: str, feature: str) -> None:
"""Raise a warning that a feature isn't implemented on a platform."""
warnings.warn(NotImplementedWarning(f"[{platform}] Not implemented: {feature}"))

Expand Down Expand Up @@ -116,7 +119,7 @@ def warn(self, platform, feature):
]


def _package_version(file, name):
def _package_version(file: Path | str | None, name: str) -> str:
try:
# Read version from SCM metadata
# This will only exist in a development environment
Expand Down
Loading
Loading