Skip to content

Commit 6dccb7e

Browse files
committed
changing lint stack
formatter and linting to ruff, and types to pyrefly
1 parent dff50f7 commit 6dccb7e

25 files changed

Lines changed: 794 additions & 100 deletions

.github/workflows/ci.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,40 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
python: ['3.10', '3.11', '3.12', '3.13']
11+
python: ['3.11', '3.12', '3.13', '3.14']
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout repository
1515
uses: actions/checkout@v2
16-
- name: Setup Python
17-
uses: actions/setup-python@v2
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v7
1818
with:
1919
python-version: ${{ matrix.python }}
2020
- name: update APT
2121
run: sudo apt-get update
2222
- name: Install dependencies
2323
run: sudo apt-get install -y libsystemd-dev
24-
- name: Install pystemd
25-
run: pip install -e '.[t]'
24+
- name: Install environment
25+
run: uv sync --all-extras --dev
26+
27+
- name: Assert Python Version
28+
run: uv run python -V
29+
2630
- name: Run unit tests
27-
run: pytest --cov=pystemd tests
31+
run: uv run pytest --cov=pystemd tests
2832

2933
formatting:
3034
runs-on: ubuntu-latest
3135
steps:
3236
- name: Checkout repository
3337
uses: actions/checkout@v2
34-
- name: Run black
35-
uses: psf/black@stable
38+
- name: Run ruff
39+
uses: astral-sh/ruff-action@v3
40+
with:
41+
src: >-
42+
pystemd
43+
examples
44+
tests
3645
- name: Run isort
3746
uses: isort/isort-action@v1
3847

@@ -42,7 +51,16 @@ jobs:
4251
steps:
4352
- name: Checkout repository
4453
uses: actions/checkout@v2
45-
- name: install mypy
46-
run: pip install mypy types-psutil
47-
- name: run mypy
48-
run: mypy
54+
- name: Install uv
55+
uses: astral-sh/setup-uv@v7
56+
57+
- name: update APT
58+
run: sudo apt-get update
59+
- name: Install dependencies
60+
run: sudo apt-get install -y libsystemd-dev
61+
62+
- name: install environment
63+
run: uv sync --extra lint
64+
- name: run pyrefly
65+
run: uv run pyrefly check pystemd examples tests
66+

examples/future_cpucap_process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __init__(self, timeout, properties):
1313
self.timeout = timeout
1414
super().__init__(properties=properties)
1515

16+
# pyrefly: ignore [bad-override]
1617
def run(self):
1718
"""
1819
This is suppose to waste a bunch of CPU.

examples/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
def list_units():
1818
with Manager() as manager:
19+
# pyrefly: ignore [missing-attribute]
1920
print("Version", manager.Manager.Version)
21+
# pyrefly: ignore [missing-attribute]
2022
print("Architecture", manager.Manager.Architecture)
2123

2224
# List Units

examples/monitor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def monitor(*args):
4848
cargs,
4949
)
5050

51+
# pyrefly: ignore [missing-attribute]
5152
name = bus.get_unique_name()
5253
while True:
5354
msg = bus.process()

examples/monitor_from_signal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def process(msg, error=None, userdata=None):
3636

3737
if msg.body[1].get(b"SubState") in (b"exited", b"failed", b"dead"):
3838
print("Unit is dead, exiting select loop")
39+
# pyrefly: ignore [missing-attribute]
3940
userdata.EXIT = True
4041
print("#" * 80)
4142
print("\n")

examples/shell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919
from pathlib import Path
2020

21+
# pyrefly: ignore [missing-import]
2122
from IPython.terminal.embed import InteractiveShellEmbed
2223

2324
import pystemd
@@ -27,9 +28,7 @@
2728

2829
display_banner = """
2930
Welcome to pystemd {pystemd.__version__} interactive shell for python {sys.version}.
30-
""".format(
31-
pystemd=pystemd, sys=sys
32-
)
31+
""".format(pystemd=pystemd, sys=sys)
3332

3433

3534
def shell() -> None:
@@ -39,6 +38,7 @@ def shell() -> None:
3938

4039

4140
def main(mod: Path) -> None:
41+
# pyrefly: ignore [bad-argument-type]
4242
runpy.run_path(mod, {}, "__main__")
4343

4444

examples/start_transient_unit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def start_transient_unit(cmd="/bin/sleep 15"):
2828
}
2929
# if we need interactive prompts for passwords, we can create our own DBus object.
3030
# if we dont need interactive, we would just do `with Manager() as manager:`.
31+
# pyrefly: ignore [unexpected-keyword]
3132
with DBus(interactive=True) as bus, Manager(bus=bus) as manager:
33+
# pyrefly: ignore [missing-argument]
3234
manager.Manager.StartTransientUnit(random_unit_name, b"fail", unit)
3335

3436
with Unit(random_unit_name, bus=bus) as unit:

pyproject.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name = "pystemd"
77
version = "0.14.0"
88
readme = "README.md"
99
description="A systemd binding for python"
10+
requires-python=">=3.11"
1011
dependencies = [
1112
"lxml",
1213
"psutil"
@@ -21,12 +22,11 @@ classifiers = [
2122
"Operating System :: POSIX :: Linux",
2223
"Intended Audience :: Developers",
2324
"Intended Audience :: System Administrators",
24-
"Programming Language :: Python :: 3.6",
25-
"Programming Language :: Python :: 3.7",
26-
"Programming Language :: Python :: 3.8",
27-
"Programming Language :: Python :: 3.9",
2825
"Programming Language :: Python :: 3.10",
2926
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
29+
"Programming Language :: Python :: 3.14",
3030
"Development Status :: 5 - Production/Stable",
3131
"Topic :: Utilities",
3232
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
@@ -40,11 +40,12 @@ t = [
4040
"pytest",
4141
"pytest-cov",
4242
# cstq and toml are used for testing version
43-
"cstq", "toml"
43+
"cstq",
44+
"toml",
4445
]
4546
lint = [
46-
"black",
47-
"mypi",
47+
"ruff",
48+
"pyrefly",
4849
"isort",
4950
]
5051

pystemd/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from typing import Any
1010

11-
from pystemd import DBus, __version__, machine1, systemd1
11+
from pystemd import machine1, systemd1
1212

1313
SDUnit = systemd1.Unit
1414
SDManager = systemd1.Manager

pystemd/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
# during development this version is always at least "one up" the
1212
# latest release.
13-
__version__ = "0.14.0"
13+
__version__ = "0.15.0"
1414

1515
sys.modules[__name__] = __version__ # type: ignore

0 commit comments

Comments
 (0)