Skip to content

Commit 29cf9f1

Browse files
authored
Modernization to 2025 standards and update for Python 3.13+ compatibility (#34)
1 parent 85e01d4 commit 29cf9f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+582
-65
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
66
RUN \
77
apt-get update \
88
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9-
git \
9+
git \
1010
&& apt-get clean \
1111
&& rm -rf /var/lib/apt/lists/*
1212

1313
WORKDIR /workspaces
1414

15+
# Upgrade pip and setuptools for Python 3.13+ compatibility
16+
RUN pip3 install -U "pip>=23.0" "setuptools>=70.0" wheel
17+
1518
# Install Python dependencies from requirements
1619
COPY requirements.txt requirements-dev.txt ./
1720
COPY docs/requirements.txt ./requirements-docs.txt

.github/workflows/ci.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
1-
name: pre-commit
1+
name: CI
22

33
"on":
4-
pull_request:
54
push:
65
branches:
76
- main
87
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
912

1013
jobs:
1114
pre-commit:
15+
name: pre-commit
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.13"
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt -r requirements-dev.txt
26+
- name: Set up Node.js (for prettier)
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "18"
30+
- name: Run pre-commit hooks
31+
uses: pre-commit/action@v3.0.0
32+
with:
33+
extra_args: --all-files
34+
35+
test:
36+
name: Run tests
1237
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
python-version: [3.13]
1341
steps:
1442
- uses: actions/checkout@v3
1543
- uses: actions/setup-python@v4
1644
with:
17-
python-version: "3.10"
45+
python-version: ${{ matrix.python-version }}
1846
- name: Install dependencies
19-
run: python3 -m pip install -r requirements.txt -r requirements-dev.txt
20-
- uses: pre-commit/action@v3.0.0
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install -r requirements.txt -r requirements-dev.txt
50+
- name: Run tests
51+
run: |
52+
if [ -f pytest.ini ] || ls tests >/dev/null 2>&1; then pytest -q; else echo "No tests found"; fi

.github/workflows/pythonpublish.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ name: Upload Python Package
44

55
"on":
66
release:
7-
types: [published]
7+
types:
8+
- published
89

910
jobs:
1011
deploy:
@@ -15,8 +16,15 @@ jobs:
1516
uses: actions/checkout@v3
1617
with:
1718
fetch-depth: 0
18-
- run: python3 -m pip install --upgrade build && python3 -m build
19-
- name: Publish package
20-
uses: pypa/gh-action-pypi-publish@release/v1
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.13"
23+
- name: Build package
24+
run: |
25+
python -m pip install --upgrade build
26+
python -m build
27+
- name: Publish package to PyPI
28+
uses: pypa/gh-action-pypi-publish@v1
2129
with:
2230
password: ${{ secrets.PYPI_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var/
2828
.installed.cfg
2929
*.egg
3030
.mypy.cache/
31+
.venv/
3132

3233
# PyInstaller
3334
# Usually these files are written by a python script from a template
@@ -68,3 +69,5 @@ example/
6869

6970
# Output when dumping to file enabled
7071
.output/*
72+
73+
ruff_cache/

.pre-commit-config.yaml

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,64 @@
11
repos:
2-
- repo: https://github.com/charliermarsh/ruff-pre-commit
3-
rev: v0.0.275
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.13.0
44
hooks:
5-
- id: ruff
6-
args:
7-
- --fix
8-
- hooks:
9-
- args: [--safe, --quiet]
5+
- id: ruff-check
6+
args: ["--fix"]
7+
- id: ruff-format
108
files: ^((pyisyox|examples)/.+)?[^/]+\.py$
11-
id: black
12-
repo: https://github.com/psf/black
13-
rev: 23.3.0
14-
- hooks:
9+
10+
- repo: https://github.com/codespell-project/codespell
11+
rev: v2.4.1
12+
hooks:
1513
- id: codespell
1614
additional_dependencies:
1715
- tomli
18-
args: [--toml, pyproject.toml]
19-
repo: https://github.com/codespell-project/codespell
20-
rev: v2.2.5
16+
args:
17+
- --toml
18+
- pyproject.toml
19+
- --ignore-words-list=ETo,ETO
20+
- --quiet-level=2
21+
exclude: ^tests/fixtures/|homeassistant/generated/|tests/components/.*/snapshots/
2122

22-
- hooks:
23-
- id: isort
24-
repo: https://github.com/PyCQA/isort
23+
- repo: https://github.com/PyCQA/isort
2524
rev: 5.12.0
25+
hooks:
26+
- id: isort
2627

2728
- repo: https://github.com/pre-commit/pre-commit-hooks
28-
rev: v4.4.0
29+
rev: v6.0.0
2930
hooks:
3031
- id: check-executables-have-shebangs
3132
stages: [manual]
3233
- id: check-json
3334
exclude: (.vscode|.devcontainer)
3435
- id: no-commit-to-branch
35-
args:
36-
- --branch=dev
37-
- --branch=main
36+
args: ["--branch=dev", "--branch=main"]
37+
3838
- repo: https://github.com/adrienverge/yamllint.git
39-
rev: v1.32.0
39+
rev: v1.37.1
4040
hooks:
4141
- id: yamllint
42-
- repo: https://github.com/pre-commit/mirrors-prettier
43-
rev: v3.0.0-alpha.9-for-vscode
42+
43+
- repo: https://github.com/rbubley/mirrors-prettier
44+
rev: v3.6.2
4445
hooks:
4546
- id: prettier
47+
additional_dependencies:
48+
- prettier@3.6.2
49+
- prettier-plugin-sort-json@4.1.1
4650

4751
- repo: local
4852
hooks:
49-
- id: pylint
50-
name: pylint
51-
entry: python3 -m pylint -j 0
52-
language: system
53-
types: [python]
54-
files: ^pyisyox/.+\.py$
55-
args: ["-rn", "-sn"]
5653
- id: mypy
5754
name: mypy
58-
entry: mypy
59-
language: system
60-
types: [python]
61-
files: ^pyisyox\/.+.py$
55+
entry: script/run-in-env.sh mypy
56+
language: script
57+
require_serial: true
58+
files: ^pyisyox/.*\.py$
59+
- id: pylint
60+
name: pylint
61+
entry: script/run-in-env.sh pylint --rcfile=.pylintrc
62+
language: script
63+
require_serial: true
64+
files: ^pyisyox/.*\.py$

.pylintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[MASTER]
2+
# Minimal pylintrc to satisfy pre-commit pylint hook.
3+
ignore=tests
4+
5+
[MESSAGES CONTROL]
6+
# Disable conventions that are noisy for this project.
7+
disable=
8+
missing-docstring,
9+
invalid-name,
10+
too-few-public-methods
11+
,too-many-instance-attributes
12+
,too-many-branches
13+
,unused-argument
14+
,too-many-statements
15+
,superfluous-parens
16+
,too-many-lines
17+
,line-too-long
18+
,useless-return
19+
,too-many-public-methods
20+
,too-many-arguments
21+
,duplicate-code
22+
,too-many-return-statements
23+
,too-many-positional-arguments

0 commit comments

Comments
 (0)