Skip to content

Commit 07ab7ca

Browse files
theCapyparasonnyp
authored andcommitted
Replace Black with Ruff, add LSP plugin for Ruff (#902)
Co-authored-by: Sonny Piers <[email protected]>
1 parent f776ae1 commit 07ab7ca

19 files changed

+8752
-155
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"prince781.vala",
1010
"bodil.blueprint-gtk",
1111
"dbaeumer.vscode-eslint",
12-
"ms-python.black-formatter"
12+
"charliermarsh.ruff"
1313
]
1414
}

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ lint:
2323
# Rust
2424
./build-aux/fun rustfmt --check --edition 2021 src/**/*.rs
2525
# Python
26-
./build-aux/fun black --check src/**/*.py
26+
./build-aux/fun ruff check --config=src/langs/python/ruff.toml src/**/*.py
27+
./build-aux/fun ruff format --config=src/langs/python/ruff.toml --check src/**/*.py
2728
# Blueprint
2829
./build-aux/fun blueprint-compiler format src/**/*.blp
2930
./build-aux/fun workbench-cli check blueprint src/**/*.blp

build-aux/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ dependencies too.
3939
In some cases you may also need to manually remove some packages the generator adds (such as `packaging` with `rope`,
4040
as the SDK and Runtime already contain a version of these packages that can not be replaced. Make sure the package
4141
you want to install is actually compatible with the version of that dependency in the SDK/Runtime.
42+
43+
#### Python packages with Maturin as build system
44+
45+
Python packages with Maturin as build system need some additional manual steps to get working. You will have to have
46+
Rust enabled for compilation and pull in additional dependencies. See `modules/python-ruff.json` for example.
47+
48+
You can generate Maturin's dependencies with another generator provided by the Flatpak Builder Tools. Clone
49+
the Maturin repo in the corresponding version you need and run:
50+
`python3 <...>/flatpak-builder-tools/cargo/flatpak-cargo-generator.py <...>/Cargo.lock -o modules/cargo-sources-maturin.json`

build-aux/modules/python-black.json

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

build-aux/modules/python-pyflakes.json

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "python3-python-lsp-ruff",
3+
"buildsystem": "simple",
4+
"build-commands": [
5+
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"python-lsp-ruff\""
6+
],
7+
"sources": [
8+
{
9+
"type": "file",
10+
"url": "https://files.pythonhosted.org/packages/e1/c7/247d04257d391251f32a7179cb74b418954022f1e9e276b5933e6ac1d3b1/python_lsp_ruff-2.2.0-py3-none-any.whl",
11+
"sha256": "fe0487c7997b38a59862c44e19cb815e24bb1b2f7cef4f1f32c61cf623a5ce94"
12+
},
13+
{
14+
"type": "file",
15+
"url": "https://files.pythonhosted.org/packages/b3/0d/cd4a4071c7f38385dc5ba91286723b4d1090b87815db48216212c6c6c30e/cattrs-23.2.3-py3-none-any.whl",
16+
"sha256": "0341994d94971052e9ee70662542699a3162ea1e0c62f7ce1b4a57f563685108"
17+
},
18+
{
19+
"type": "file",
20+
"url": "https://files.pythonhosted.org/packages/8d/37/2351e48cb3309673492d3a8c59d407b75fb6630e560eb27ecd4da03adc9a/lsprotocol-2023.0.1-py3-none-any.whl",
21+
"sha256": "c75223c9e4af2f24272b14c6375787438279369236cd568f596d4951052a60f2"
22+
},
23+
{
24+
"type": "file",
25+
"url": "https://files.pythonhosted.org/packages/91/f7/3b9c3a588e46bbdc2671d8fd07ecee118a672db50d72656b5726fbeffbcd/python_lsp_server-1.10.0-py3-none-any.whl",
26+
"sha256": "1a9f338bd7cf3cdde5ae85a2bd93fd5be9e55249f6482d88f99fb6227215424a"
27+
},
28+
{
29+
"type": "file",
30+
"url": "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl",
31+
"sha256": "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"
32+
},
33+
{
34+
"type": "file",
35+
"url": "https://files.pythonhosted.org/packages/20/9f/bc63f0f0737ad7a60800bfd472a4836661adae21f9c2535f3957b1e54ceb/jedi-0.19.1-py2.py3-none-any.whl",
36+
"sha256": "e983c654fe5c02867aef4cdfce5a2fbb4a50adc0af145f70504238f18ef5e7e0"
37+
},
38+
{
39+
"type": "file",
40+
"url": "https://files.pythonhosted.org/packages/a5/5b/0cc789b59e8cc1bf288b38111d002d8c5917123194d45b29dcdac64723cc/pluggy-1.4.0-py3-none-any.whl",
41+
"sha256": "7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"
42+
},
43+
{
44+
"type": "file",
45+
"url": "https://files.pythonhosted.org/packages/cb/d9/656659d5b5d5f402b2b174cd0ba9bc827e07ce3c0bf88da65424baf64af8/python_lsp_jsonrpc-1.1.2-py3-none-any.whl",
46+
"sha256": "7339c2e9630ae98903fdaea1ace8c47fba0484983794d6aafd0bd8989be2b03c"
47+
},
48+
{
49+
"type": "file",
50+
"url": "https://files.pythonhosted.org/packages/6e/54/6f2bdac7117e89a47de4511c9f01732a283457ab1bf856e1e51aa861619e/ujson-5.9.0.tar.gz",
51+
"sha256": "89cc92e73d5501b8a7f48575eeb14ad27156ad092c2e9fc7e3cf949f07e75532"
52+
},
53+
{
54+
"type": "file",
55+
"url": "https://files.pythonhosted.org/packages/c1/cf/4eee59f6c4111b3e80cc32cf6bac483a90646f5c8693e84496c9855e8e38/docstring_to_markdown-0.15-py3-none-any.whl",
56+
"sha256": "27afb3faedba81e34c33521c32bbd258d7fbb79eedf7d29bc4e81080e854aec0"
57+
},
58+
{
59+
"type": "file",
60+
"url": "https://files.pythonhosted.org/packages/05/63/8011bd08a4111858f79d2b09aad86638490d62fbf881c44e434a6dfca87b/parso-0.8.3-py2.py3-none-any.whl",
61+
"sha256": "c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75"
62+
}
63+
]
64+
}

build-aux/modules/python-ruff.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "python3-ruff",
3+
"buildsystem": "simple",
4+
"build-commands": [
5+
". /usr/lib/sdk/rust-stable/enable.sh && pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"ruff\""
6+
],
7+
"build-options": {
8+
"env": {
9+
"CARGO_HOME": "/run/build/python3-ruff/cargo",
10+
"CARGO_NET_OFFLINE": "true"
11+
}
12+
},
13+
"sources": [
14+
{
15+
"type": "file",
16+
"url": "https://files.pythonhosted.org/packages/20/90/43a3aa35f037e91582ec7516a92084a71f84e89e39ef580813bed072b154/maturin-1.4.0.tar.gz",
17+
"sha256": "ed12e1768094a7adeafc3a74ebdb8dc2201fa64c4e7e31f14cfc70378bf93790"
18+
},
19+
"sources/cargo-sources-maturin.json",
20+
{
21+
"type": "file",
22+
"url": "https://files.pythonhosted.org/packages/ef/cc/93f7213b2ab5ed383f98ce8020e632ef256b406b8569606c3f160ed8e1c9/setuptools-68.2.2.tar.gz",
23+
"sha256": "4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"
24+
},
25+
{
26+
"type": "file",
27+
"url": "https://files.pythonhosted.org/packages/c7/c3/55076fc728723ef927521abaa1955213d094933dc36d4a2008d5101e1af5/wheel-0.42.0-py3-none-any.whl",
28+
"sha256": "177f9c9b0d45c47873b619f5b650346d632cdc35fb5e4d25058e09c9e581433d"
29+
},
30+
{
31+
"type": "file",
32+
"url": "https://files.pythonhosted.org/packages/f7/7f/8b1c33598b03ad612b8ced223f9ca54076b789fabf5a66ce37cc096d9cf7/setuptools_rust-1.9.0-py3-none-any.whl",
33+
"sha256": "409caf49dcf7ad9bd510b4bf4011fbad504e745fae98f57fe1c06f3a97719638"
34+
},
35+
{
36+
"type": "file",
37+
"url": "https://files.pythonhosted.org/packages/6a/23/8146aad7d88f4fcb3a6218f41a60f6c2d4e3a72de72da1825dc7c8f7877c/semantic_version-2.10.0-py2.py3-none-any.whl",
38+
"sha256": "de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177"
39+
},
40+
41+
{
42+
"type": "file",
43+
"url": "https://files.pythonhosted.org/packages/61/b0/5fb64bc79464823ca94e566c9000143ddc11f9396c6e20202315059dd64f/ruff-0.3.0.tar.gz",
44+
"sha256": "0886184ba2618d815067cf43e005388967b67ab9c80df52b32ec1152ab49f53a"
45+
},
46+
"sources/cargo-sources-ruff.json"
47+
]
48+
}

0 commit comments

Comments
 (0)