Skip to content

new infrastructure files, use ruff, update for new displayio API #2

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

Merged
merged 2 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 2 additions & 68 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,5 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Translate Repo Name For Build Tools filename_prefix
id: repo-name
run: |
echo ::set-output name=repo-name::$(
echo ${{ github.repository }} |
awk -F '\/' '{ print tolower($2) }' |
tr '_' '-'
)
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Versions
run: |
python3 --version
- name: Checkout Current Repo
uses: actions/checkout@v1
with:
submodules: true
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: adafruit/actions-ci-circuitpython-libs
path: actions-ci
- name: Install dependencies
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
run: |
source actions-ci/install.sh
- name: Pip install pylint, Sphinx, pre-commit
run: |
pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit
- name: Library version
run: git describe --dirty --always --tags
- name: Setup problem matchers
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
- name: Pre-commit hooks
run: |
pre-commit run --all-files
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
- name: Archive bundles
uses: actions/upload-artifact@v2
with:
name: bundles
path: ${{ github.workspace }}/bundles/
- name: Check For docs folder
id: need-docs
run: |
echo ::set-output name=docs::$( find . -wholename './docs' )
- name: Build docs
if: contains(steps.need-docs.outputs.docs, 'docs')
working-directory: docs
run: sphinx-build -E -W -b html . _build/html
- name: Check For setup.py
id: need-pypi
run: |
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
- name: Build Python package
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
run: |
pip install --upgrade setuptools wheel twine readme_renderer testresources
python setup.py sdist
python setup.py bdist_wheel --universal
twine check dist/*
- name: Run Build CI workflow
uses: adafruit/workflows-circuitpython-libs/build@main
88 changes: 0 additions & 88 deletions .github/workflows/release.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/release_gh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT

name: GitHub Release Actions

on:
release:
types: [published]

jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Run GitHub Release CI workflow
uses: adafruit/workflows-circuitpython-libs/release-gh@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
upload-url: ${{ github.event.release.upload_url }}
# TODO: If you're creating a package (library is a folder), add this
# argument along with the prefix (or full name) of the package folder
# so the MPY bundles are built correctly:s
# package-prefix: displayio_effects
19 changes: 19 additions & 0 deletions .github/workflows/release_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT

name: PyPI Release Actions

on:
release:
types: [published]

jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Run PyPI Release CI workflow
uses: adafruit/workflows-circuitpython-libs/release-pypi@main
with:
pypi-username: ${{ secrets.pypi_username }}
pypi-password: ${{ secrets.pypi_password }}
47 changes: 14 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

repos:
- repo: https://github.com/python/black
rev: 20.8b1
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: black
- repo: https://github.com/fsfe/reuse-tool
rev: v0.12.1
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
- id: ruff-format
- id: ruff
args: ["--fix"]
- repo: https://github.com/fsfe/reuse-tool
rev: v3.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: pylint-2.7.1
hooks:
- id: pylint
name: pylint (library code)
types: [python]
exclude: "^(docs/|examples/|tests/|setup.py$)"
- repo: local
hooks:
- id: pylint_examples
name: pylint (examples code)
description: Run pylint rules on "examples/*.py" files
entry: /usr/bin/env bash -c
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name,consider-using-f-string $example; done)']
language: system
- id: pylint_tests
name: pylint (tests code)
description: Run pylint rules on "tests/*.py" files
entry: /usr/bin/env bash -c
args: ['([[ ! -d "tests" ]] || for test in $(find . -path "./tests/*.py"); do pylint --disable=missing-docstring $test; done)']
language: system
- id: reuse
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
# Required
version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-20.04
os: ubuntu-lts-latest
tools:
python: "3"

Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Introduction
:alt: Build Status


.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: Black
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Code Style: Ruff

Add some flair to your widgets with effects!

Expand Down
2 changes: 1 addition & 1 deletion displayio_effects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
https://circuitpython.org/downloads
"""


WIDGET_TYPE_ATTR = "_widget_type"


# pylint: disable=too-few-public-methods
class WidgetType:
"""Enum values for customizable widget types. Valid options are:
Expand Down
11 changes: 5 additions & 6 deletions displayio_effects/colorwheel_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT
# pylint: disable=protected-access
"""
`displayio_effects.fluctuation_effect`
`displayio_effects.colorwheel_effect`
================================================================================

Add the colorwheel effect to your widgets
Expand All @@ -21,9 +21,10 @@
https://circuitpython.org/downloads
"""

from adafruit_itertools import cycle
from rainbowio import colorwheel
from adafruit_itertools.adafruit_itertools import cycle
from displayio_effects import WidgetType, WIDGET_TYPE_ATTR

from displayio_effects import WIDGET_TYPE_ATTR, WidgetType

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/tekktrik/CircuitPython_Org_DisplayIO_Effects.git"
Expand Down Expand Up @@ -69,9 +70,7 @@ def hook_colorwheel_effect(widget_class, widget_type):
"""

if not COLORWHEEL_WIDGET_VALUES.get(widget_type):
raise ValueError(
"The given widget does not have the ability to use this effect"
)
raise ValueError("The given widget does not have the ability to use this effect")

setattr(widget_class, WIDGET_TYPE_ATTR, widget_type)

Expand Down
12 changes: 5 additions & 7 deletions displayio_effects/fluctuation_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"""

import random
from displayio_effects import WidgetType, WIDGET_TYPE_ATTR

from displayio_effects import WIDGET_TYPE_ATTR, WidgetType

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/tekktrik/CircuitPython_Org_DisplayIO_Effects.git"
Expand Down Expand Up @@ -79,11 +80,10 @@ def update_fluctuation(self):
self._fluctuation_destination = None
return

if self._fluctuation_destination in (None, self._fluctuation_hold_value):
if self._fluctuation_destination in {None, self._fluctuation_hold_value}:
limit_bound = self._fluctuation_amplitude * 10
self._fluctuation_destination = (
random.uniform(-limit_bound, limit_bound) / 10
+ self._fluctuation_hold_value
random.uniform(-limit_bound, limit_bound) / 10 + self._fluctuation_hold_value
)

value = getattr(self, value_name)
Expand Down Expand Up @@ -124,9 +124,7 @@ def hook_fluctuation_effect(widget_class, widget_type):
"""

if not FLUCTUATION_WIDGET_VALUES.get(widget_type):
raise ValueError(
"The given widget does not have the ability to use this effect"
)
raise ValueError("The given widget does not have the ability to use this effect")

setattr(widget_class, WIDGET_TYPE_ATTR, widget_type)

Expand Down
6 changes: 6 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
.. use this format as the module name: "adafruit_foo.foo"

API Reference
#############

.. automodule:: displayio_effects.fluctuation_effect
:members:

.. automodule:: displayio_effects.colorwheel_effect
:members:
Loading