Skip to content

Commit 96f3b31

Browse files
committed
chore: migrate to modern tooling
1 parent b6f6aa5 commit 96f3b31

File tree

9 files changed

+228
-832
lines changed

9 files changed

+228
-832
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616
- name: 🏗 Set up Python 3.10
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: "3.10"
2020
- name: 🏗 Install build dependencies
2121
run: >-
22-
python -m pip install wheel --user
22+
python -m pip install wheel build --user
2323
- name: 🔨 Build a binary wheel and a source tarball
2424
run: >-
25-
python setup.py sdist bdist_wheel
25+
python -m build
2626
- name: ⬆ Upload build result
2727
uses: actions/upload-artifact@v4
2828
with:

.pre-commit-config.yaml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exclude: ^(octoprint_pi_support/translations|extras/|translations/|.*\.css|.*\.svg)
1+
exclude: ^(octoprint_firmware_check/translations|extras/|translations/|.*\.css|.*\.svg)
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
44
rev: v4.4.0
@@ -17,27 +17,12 @@ repos:
1717
hooks:
1818
- id: pyupgrade
1919
args: ["--py37-plus"]
20-
- repo: https://github.com/OctoPrint/codemods
21-
rev: "0.6.3"
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.4.2
2222
hooks:
23-
- id: codemod_not_in
24-
- repo: https://github.com/pre-commit/mirrors-isort
25-
rev: v5.10.1
26-
hooks:
27-
- id: isort
28-
- repo: https://github.com/psf/black
29-
rev: 23.1.0
30-
hooks:
31-
- id: black
32-
args: ["--config", "black.toml"]
33-
additional_dependencies:
34-
- click==8.0.4
35-
- repo: https://github.com/pycqa/flake8
36-
rev: 6.0.0
37-
hooks:
38-
- id: flake8
39-
additional_dependencies:
40-
- flake8-bugbear
23+
- id: ruff
24+
args: ["--fix"]
25+
- id: ruff-format
4126
- repo: https://github.com/pre-commit/mirrors-prettier
4227
rev: v3.0.0-alpha.4
4328
hooks:

Taskfile.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
# https://taskfile.dev
3+
4+
version: "3"
5+
6+
env:
7+
LOCALES: ["de"] # list your included locales here, e.g. ["de", "fr"]
8+
TRANSLATIONS: "octoprint_pi_support/translations" # translations folder, do not touch
9+
10+
11+
tasks:
12+
install:
13+
desc: Installs the plugin into the current venv
14+
cmds:
15+
- "python -m pip install -e .[develop]"
16+
17+
test:
18+
desc: Run the plugin's test suite
19+
cmds:
20+
- "python -m pytest"
21+
22+
### Build related
23+
24+
build:
25+
desc: Builds sdist & wheel
26+
cmds:
27+
- python -m build --sdist --wheel
28+
29+
build-sdist:
30+
desc: Builds sdist
31+
cmds:
32+
- python -m build --sdist
33+
34+
build-wheel:
35+
desc: Builds wheel
36+
cmds:
37+
- python -m build --wheel
38+
39+
### Translation related
40+
41+
babel-new:
42+
desc: Create a new translation for a locale
43+
cmds:
44+
- task: babel-extract
45+
- |
46+
pybabel init --input-file=translations/messages.pot --output-dir=translations --locale="{{ .CLI_ARGS }}"
47+
48+
babel-extract:
49+
desc: Update pot file from source
50+
cmds:
51+
- pybabel extract --mapping-file=babel.cfg --output-file=translations/messages.pot [email protected] --copyright-holder="The OctoPrint Project" .
52+
53+
babel-update:
54+
desc: Update translation files from pot file
55+
cmds:
56+
- for:
57+
var: LOCALES
58+
cmd: pybabel update --input-file=translations/messages.pot --output-dir=translations --locale={{ .ITEM }}
59+
60+
babel-refresh:
61+
desc: Update translation files from source
62+
cmds:
63+
- task: babel-extract
64+
- task: babel-update
65+
66+
babel-compile:
67+
desc: Compile translation files
68+
cmds:
69+
- pybabel compile --directory=translations
70+
71+
babel-bundle:
72+
desc: Bundle translations
73+
preconditions:
74+
- test -d {{ .TRANSLATIONS }}
75+
cmds:
76+
- for:
77+
var: LOCALES
78+
cmd: |
79+
locale="{{ .ITEM }}"
80+
source="translations/${locale}"
81+
target="{{ .TRANSLATIONS }}/${locale}"
82+
83+
[ ! -d "${target}" ] || rm -r "${target}"
84+
85+
echo "Copying translations for locale ${locale} from ${source} to ${target}..."
86+
cp -r "${source}" "${target}"

black.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

octoprint_pi_support/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def is_new_camerastack():
261261

262262
def is_model_any_of(model, *args):
263263
model = model.lower()
264-
for arg in map(lambda x: x.lower(), args):
264+
for arg in (x.lower() for x in args):
265265
if f"{arg} rev" in model or model.endswith(arg):
266266
return True
267267
return False
@@ -496,31 +496,31 @@ def get_settings_restricted_paths(self):
496496
##~~ Softwareupdate hook
497497

498498
def get_update_information(self):
499-
return dict(
500-
pi_support=dict(
501-
displayName="Pi Support Plugin",
502-
displayVersion=self._plugin_version,
499+
return {
500+
"pi_support": {
501+
"displayName": "Pi Support Plugin",
502+
"displayVersion": self._plugin_version,
503503
# version check: github repository
504-
type="github_release",
505-
user="OctoPrint",
506-
repo="OctoPrint-PiSupport",
507-
current=self._plugin_version,
508-
stable_branch={
504+
"type": "github_release",
505+
"user": "OctoPrint",
506+
"repo": "OctoPrint-PiSupport",
507+
"current": self._plugin_version,
508+
"stable_branch": {
509509
"name": "Stable",
510510
"branch": "main",
511511
"commitish": ["devel", "main"],
512512
},
513-
prerelease_branches=[
513+
"prerelease_branches": [
514514
{
515515
"name": "Prerelease",
516516
"branch": "devel",
517517
"commitish": ["devel", "main"],
518518
}
519519
],
520520
# update method: pip
521-
pip="https://github.com/OctoPrint/OctoPrint-PiSupport/archive/{target_version}.zip",
522-
)
523-
)
521+
"pip": "https://github.com/OctoPrint/OctoPrint-PiSupport/archive/{target_version}.zip",
522+
}
523+
}
524524

525525
# ~~ Helpers
526526

pyproject.toml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=67",
4+
"wheel",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "OctoPrint-PiSupport"
10+
version = "2023.10.10"
11+
description = "Provides additional information about your Pi in the UI"
12+
authors = [
13+
{ name = "Gina Häußge", email = "[email protected]" },
14+
]
15+
license = "AGPL-3.0-or-later"
16+
requires-python = ">=3.7,<4"
17+
dependencies = []
18+
19+
[project.entry-points."octoprint.plugin"]
20+
pi_support = "octoprint_pi_support"
21+
22+
[project.urls]
23+
Homepage = "https://github.com/OctoPrint/OctoPrint-PiSupport"
24+
25+
[project.optional-dependencies]
26+
develop = [
27+
"go-task-bin",
28+
]
29+
30+
[project.readme]
31+
file = "README.md"
32+
content-type = "markdown"
33+
34+
[tool.setuptools]
35+
include-package-data = true
36+
packages = [
37+
"octoprint_pi_support",
38+
]
39+
40+
[tool.ruff]
41+
exclude = [
42+
# standard stuff
43+
".bzr",
44+
".direnv",
45+
".eggs",
46+
".git",
47+
".git-rewrite",
48+
".hg",
49+
".ipynb_checkpoints",
50+
".mypy_cache",
51+
".nox",
52+
".pants.d",
53+
".pyenv",
54+
".pytest_cache",
55+
".pytype",
56+
".ruff_cache",
57+
".svn",
58+
".tox",
59+
".venv",
60+
".vscode",
61+
"__pypackages__",
62+
"_build",
63+
"buck-out",
64+
"build",
65+
"dist",
66+
"node_modules",
67+
"site-packages",
68+
"venv",
69+
]
70+
71+
line-length = 90
72+
indent-width = 4
73+
74+
# Assume Python 3.7
75+
target-version = "py37"
76+
77+
[tool.ruff.lint]
78+
select = ["B", "C", "E", "F", "I", "W", "B9"]
79+
ignore = [
80+
"E203",
81+
"E231",
82+
"E265",
83+
"E266",
84+
"E402",
85+
"E501",
86+
"E731",
87+
"E741",
88+
"W605",
89+
"C901",
90+
]
91+
fixable = ["I", "C4", "E"]
92+
93+
# Allow unused variables when underscore-prefixed.
94+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
95+
96+
[tool.ruff.lint.isort]
97+
known-first-party = [
98+
"octoprint_file_check",
99+
]
100+
101+
[tool.ruff.format]
102+
quote-style = "double"
103+
indent-style = "space"
104+
skip-magic-trailing-comma = false
105+
line-ending = "lf"
106+
107+
# Enable auto-formatting of code examples in docstrings. Markdown,
108+
# reStructuredText code/literal blocks and doctests are all supported.
109+
#
110+
# This is currently disabled by default, but it is planned for this
111+
# to be opt-out in the future.
112+
docstring-code-format = false
113+
114+
# Set the line length limit used when formatting code snippets in
115+
# docstrings.
116+
#
117+
# This only has an effect when the `docstring-code-format` setting is
118+
# enabled.
119+
docstring-code-line-length = "dynamic"

requirements.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)