Skip to content

Commit

Permalink
Merge pull request #2252 from rmartin16/api-types-testing
Browse files Browse the repository at this point in the history
Typing updates
  • Loading branch information
freakboy3742 authored Jun 11, 2024
2 parents 1ae8563 + 9145b98 commit 04daf6f
Show file tree
Hide file tree
Showing 74 changed files with 1,510 additions and 1,007 deletions.
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

0 comments on commit 04daf6f

Please sign in to comment.