Skip to content

Commit

Permalink
Merge branch 'beeware:main' into patch-20
Browse files Browse the repository at this point in the history
  • Loading branch information
proneon267 authored Jul 19, 2024
2 parents a30a8e3 + 47ce375 commit a4eb081
Show file tree
Hide file tree
Showing 29 changed files with 257 additions and 31 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.1.1
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -118,7 +118,7 @@ jobs:
project-root: core

- name: Get Packages
uses: actions/download-artifact@v4.1.7
uses: actions/download-artifact@v4.1.8
with:
pattern: ${{ format('{0}-*', needs.package.outputs.artifact-basename) }}
merge-multiple: true
Expand All @@ -134,7 +134,7 @@ jobs:
mv core/.coverage core/.coverage.${{ matrix.platform }}.${{ matrix.python-version }}
- name: Store Coverage Data
uses: actions/upload-artifact@v4.3.3
uses: actions/upload-artifact@v4.3.4
with:
name: core-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }}
path: "core/.coverage.*"
Expand All @@ -151,7 +151,7 @@ jobs:
fetch-depth: 0

- name: Set up Python ${{ env.min_python_version }}
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.1.1
with:
# Use minimum version of python for coverage to avoid phantom branches
# https://github.com/nedbat/coveragepy/issues/1572#issuecomment-1522546425
Expand All @@ -165,7 +165,7 @@ jobs:
project-root: core

- name: Retrieve Coverage Data
uses: actions/download-artifact@v4.1.7
uses: actions/download-artifact@v4.1.8
with:
pattern: core-coverage-data-*
path: core
Expand All @@ -175,7 +175,7 @@ jobs:
run: tox -e coverage-html-fail-platform

- name: Upload HTML Coverage Report
uses: actions/upload-artifact@v4.3.3
uses: actions/upload-artifact@v4.3.4
if: failure()
with:
name: html-coverage-report
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.1.1
if: matrix.setup-python
with:
# We're not using Python 3.11 yet, because:
Expand All @@ -333,7 +333,7 @@ jobs:
briefcase run ${{ matrix.platform }} --log --test ${{ matrix.briefcase-run-args }} -- --ci
- name: Upload Logs
uses: actions/upload-artifact@v4.3.3
uses: actions/upload-artifact@v4.3.4
if: failure()
with:
name: testbed-failure-logs-${{ matrix.backend }}
Expand All @@ -346,7 +346,7 @@ jobs:
cp -r "${{ matrix.app-user-data-path }}" testbed/app_data/testbed-app_data-${{ matrix.backend }}
- name: Upload App Data
uses: actions/upload-artifact@v4.3.3
uses: actions/upload-artifact@v4.3.4
if: failure() && matrix.backend != 'android'
with:
name: testbed-failure-app-data-${{ matrix.backend }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
echo "VERSION=${GITHUB_REF_NAME#v}" | tee -a $GITHUB_ENV
- name: Get Packages
uses: actions/download-artifact@v4.1.7
uses: actions/download-artifact@v4.1.8
with:
pattern: ${{ format('{0}-*', needs.ci.outputs.artifact-basename) }}
merge-multiple: true
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
- "toga_winforms"
steps:
- name: Get Packages
uses: actions/download-artifact@v4.1.7
uses: actions/download-artifact@v4.1.8
with:
pattern: ${{ format('{0}-*', needs.ci.outputs.artifact-basename) }}
merge-multiple: true
Expand Down
2 changes: 1 addition & 1 deletion android/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools==70.1.1",
"setuptools==70.3.0",
"setuptools_scm==8.1.0",
"setuptools_dynamic_dependencies @ git+https://github.com/beeware/setuptools_dynamic_dependencies",
]
Expand Down
1 change: 1 addition & 0 deletions changes/2693.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated sphinx-toolbox from 3.6.0 to 3.7.0 in /core.
1 change: 1 addition & 0 deletions changes/2694.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated pillow from 10.3.0 to 10.4.0 in /core.
1 change: 1 addition & 0 deletions changes/2695.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated tox from 4.15.1 to 4.16.0 in /core.
1 change: 1 addition & 0 deletions changes/2696.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The pinned dependencies in pyproject.toml and tox.ini were updated to their latest versions.
1 change: 1 addition & 0 deletions changes/2697.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated actions/upload-artifact from 4.3.3 to 4.3.4.
1 change: 1 addition & 0 deletions changes/2698.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated actions/download-artifact from 4.1.7 to 4.1.8.
1 change: 1 addition & 0 deletions changes/2699.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated fonttools from 4.53.0 to 4.53.1 in /testbed.
1 change: 1 addition & 0 deletions changes/2701.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CommandSet now exposes a full set and dictionary interface. Commands can be added to a CommandSet using ``[]`` notation and a command ID; they can be removed using set-like ``remove()`` or ``discard()`` calls with a Command instance, or using dictionary-like ``pop()`` or ``del`` calls with the command ID.
1 change: 1 addition & 0 deletions changes/2709.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated actions/setup-python from 5.1.0 to 5.1.1.
1 change: 1 addition & 0 deletions changes/2710.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated coverage[toml] from 7.5.4 to 7.6.0 in /core.
1 change: 1 addition & 0 deletions changes/2711.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The pinned dependencies in pyproject.toml and tox.ini were updated to their latest versions.
1 change: 1 addition & 0 deletions changes/2712.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated coverage from 7.5.4 to 7.6.0 in /testbed.
2 changes: 1 addition & 1 deletion cocoa/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools==70.1.1",
"setuptools==70.3.0",
"setuptools_scm==8.1.0",
"setuptools_dynamic_dependencies @ git+https://github.com/beeware/setuptools_dynamic_dependencies",
]
Expand Down
12 changes: 6 additions & 6 deletions core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools==70.1.1",
"setuptools==70.3.0",
"setuptools_scm==8.1.0",
"setuptools_dynamic_dependencies @ git+https://github.com/beeware/setuptools_dynamic_dependencies",
]
Expand Down Expand Up @@ -66,23 +66,23 @@ dependencies = [
# Extras used by developers *of* Toga are pinned to specific versions to
# ensure environment consistency.
dev = [
"coverage[toml] == 7.5.4",
"coverage[toml] == 7.6.0",
"coverage-conditional-plugin == 0.9.0",
"Pillow == 10.3.0",
"Pillow == 10.4.0",
# Pre-commit 3.6.0 deprecated support for Python 3.8
"pre-commit == 3.5.0 ; python_version < '3.9'",
"pre-commit == 3.7.1 ; python_version >= '3.9'",
"pytest == 8.2.2",
"pytest-asyncio == 0.23.7",
"pytest-freezer == 0.4.8",
"setuptools-scm == 8.1.0",
"tox == 4.15.1",
"tox == 4.16.0",
# typing-extensions needed for TypeAlias added in Py 3.10
"typing-extensions == 4.9.0 ; python_version < '3.10'",
]
docs = [
"furo == 2024.5.6",
"Pillow == 10.3.0",
"Pillow == 10.4.0",
"pyenchant == 3.2.2",
# Sphinx 7.2 deprecated support for Python 3.8
"sphinx == 7.1.2 ; python_version < '3.9'",
Expand All @@ -93,7 +93,7 @@ docs = [
"sphinx-autobuild == 2024.4.16 ; python_version >= '3.9'",
"sphinx-csv-filter == 0.4.1",
"sphinx-copybutton == 0.5.2",
"sphinx-toolbox == 3.6.0",
"sphinx-toolbox == 3.7.0",
"sphinxcontrib-spelling == 8.0.0",
]

Expand Down
23 changes: 21 additions & 2 deletions core/src/toga/command.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Iterator
from typing import TYPE_CHECKING, Protocol
from typing import TYPE_CHECKING, MutableMapping, MutableSet, Protocol

from toga.handlers import wrapped_handler
from toga.icons import Icon
Expand Down Expand Up @@ -325,7 +325,7 @@ def __call__(self, **kwargs) -> object:
"""


class CommandSet:
class CommandSet(MutableSet[Command], MutableMapping[str, Command]):
def __init__(
self,
on_change: CommandSetChangeHandler | None = None,
Expand Down Expand Up @@ -392,6 +392,25 @@ def __contains__(self, obj: str | Command) -> Command:
def __getitem__(self, id: str) -> Command:
return self._commands[id]

def __setitem__(self, id: str, command: Command) -> Command:
if id != command.id:
raise ValueError(f"Command has id {command.id!r}; can't add as {id!r}")

self.add(command)

def __delitem__(self, id: str) -> Command:
del self._commands[id]
if self.on_change:
self.on_change()

def discard(self, command: Command):
try:
self._commands.pop(command.id)
if self.on_change:
self.on_change()
except KeyError:
pass

def __len__(self) -> int:
return len(self._commands)

Expand Down
Loading

0 comments on commit a4eb081

Please sign in to comment.