beeware / beeware/toga

Formalize a Style typing protocol

Open
#2,045 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
9h 45m
Merged PRs (30d)
58

Description

### What is the problem or limitation you are having?

(Created after in-person discussion with @freakboy3742)

Currently, there is no good way to provide a type annotation for the `style` parameter of many `__init__` methods (e.g. Widget). In practice, it usually boils down to `toga.style.Pack`, but other implementations of `travertino.declaration.BaseStyle` or third-party libraries should be allowed.

### Describe the solution you'd like

toga should specify a `typing.Protocol` for styles, which can be satisfied by travertino and other style providers. This protocol can then be used for type annotations as well.

### Describe alternatives you've considered

-

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

The issue concerns style parameters on __init__ methods such as Widget, along with toga.style.Pack and travertino.declaration.BaseStyle. Start by locating those annotations and reviewing the typing.Protocol requirements; done means the protocol supports travertino and third-party styles and is used in the relevant annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.