Skip to content

Commit 4c95b57

Browse files
committed
pyproject.toml: Add dependency_groups.
pyproject.toml: Add dependency_groups for typing, test, and dev. Minor reformatting. .pre-commit-config.yaml: Update to use uv-pre-commit and ruff-pre-commit hooks. uv.lock and requirements.txt: Regenerated after `uv sync update`. Minor update to README.md and pre-commit config. pyproject.toml: Add `static` and `test` labels for tox. More pre-commit tweaks. Minor change to ruff config and fix some linting issues. mpfsops.py: Minor formatting fix for ruff. Remove lock runner
1 parent 2ad1082 commit 4c95b57

File tree

8 files changed

+1113
-357
lines changed

8 files changed

+1113
-357
lines changed

.pre-commit-config.yaml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,31 @@ default_install_hook_types: [pre-commit, pre-merge-commit, pre-push]
22
default_stages: [pre-commit, pre-merge-commit, pre-push, manual]
33
exclude: (^tests/.*/.*$)
44
repos:
5-
- repo: local
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.6.0
7+
hooks:
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- repo: https://github.com/astral-sh/uv-pre-commit
12+
rev: 0.6.13
13+
hooks:
14+
- id: uv-lock # Ensure lockfile is up to date
15+
- id: uv-export # Export the lockfile to requirements.txt
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.11.4
618
hooks:
719
- id: ruff
8-
name: ruff
9-
description: "Run 'ruff' for extremely fast Python linting"
10-
entry: uv run ruff check --force-exclude --no-fix
20+
args: [ --no-fix]
1121
always_run: true
12-
language: python
13-
types_or: [python, pyi, jupyter]
14-
args: []
15-
require_serial: true
16-
additional_dependencies: []
17-
minimum_pre_commit_version: "2.9.2"
1822
- id: ruff-format
19-
name: ruff-format
20-
description: "Run 'ruff format' for extremely fast Python formatting"
21-
entry: uv run ruff format --check --force-exclude
2223
always_run: true
23-
language: python
24-
types_or: [python, pyi, jupyter]
25-
args: []
26-
require_serial: true
27-
additional_dependencies: []
28-
minimum_pre_commit_version: "2.9.2"
24+
25+
- repo: local
26+
hooks:
2927
- id: mypy
3028
name: mypy
3129
entry: uv run mypy
32-
files: ^(src|tests)/.*\.py$
3330
always_run: true
3431
language: python
3532
types: [python]

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
[![PyPI - License](
1616
https://img.shields.io/pypi/l/mpremote-path)](
1717
https://opensource.org/licenses/MIT)
18+
[![pre-commit](
19+
https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](
20+
https://github.com/pre-commit/pre-commit)
1821

1922
Provides a convenient,
2023
[`pathlib`](https://docs.python.org/3/library/pathlib.html) compatible python
@@ -23,9 +26,7 @@ interface to access and manipulate files on a serial-attached
2326
computer. **mpremote-path** provides the `MPRemotePath` class which implements a
2427
`pathlib.Path` compatible interface to the file access features of the
2528
[mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) tool.
26-
27-
Version 0.1.2 passes all tests on windows and linux for python versions 3.8,
28-
3.9, 3.10, 3.11, 3.12 and 3.13.
29+
Tested on Linux, Windows and MacOS.
2930

3031
**Contents:**
3132

pyproject.toml

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
1-
[build-system]
2-
requires = ["hatchling", "hatch-vcs"]
3-
build-backend = "hatchling.build"
4-
51
[project]
62
name = "mpremote-path"
73
description = "Pathlib compatible interface to files on a MicroPython device"
4+
readme = "README.md"
85
authors = [{name = "glenn20", email = "[email protected]"}]
96
urls = {Homepage = "https://github.com/glenn20/mpremote-path"}
10-
readme = "README.md"
117
license = {text = "MIT"}
128
classifiers = [
139
"License :: OSI Approved :: MIT License",
1410
"Intended Audience :: Developers",
1511
"Operating System :: OS Independent",
1612
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3 :: Only",
18-
"Programming Language :: Python :: 3.8",
19-
"Programming Language :: Python :: 3.9",
20-
"Programming Language :: Python :: 3.10",
21-
"Programming Language :: Python :: 3.11",
22-
"Programming Language :: Python :: 3.12",
23-
"Programming Language :: Python :: 3.13",
2413
"Topic :: Software Development :: Embedded Systems",
2514
"Topic :: Software Development :: Libraries",
2615
"Typing :: Typed",
2716
]
2817
requires-python = ">=3.9"
18+
dynamic = ["version"]
2919
dependencies = [
30-
"mpremote >= 1.20.0, != 1.24.0"
20+
"mpremote >= 1.20.0, != 1.24.0",
3121
]
32-
dynamic = ["version"]
3322

3423
[project.scripts]
3524
mpfs = "mpremote_path.util.mpfs:main"
3625

26+
[dependency-groups]
27+
typing = ["mypy>=0.910", "types-pyserial>=3.5", "types-pyyaml>=6.0.0"]
28+
test = [
29+
{include-group = "typing"},
30+
"ruff>=0.6.7", "pytest>=8.3.2", "pytest-cov>=3.0.0",
31+
"pyyaml>=6.0.0", "tox>=4.22", "tox-uv>=1.13",
32+
]
33+
dev = [
34+
{include-group = "test"},
35+
"hatch>=1.12.0", "hatch-vcs>=0.3.0", # For building and updating _version.py
36+
"pre-commit>=2.9.2", "pre-commit-uv>=4.0", "pip>=23.0.1", # pre-commit hooks
37+
]
38+
39+
[build-system]
40+
requires = ["hatchling", "hatch-vcs"]
41+
build-backend = "hatchling.build"
42+
3743
[tool.hatch]
38-
# version.path = "src/mpremote_path/__init__.py"
39-
version.source = "vcs" # Get the version from git, eg: 0.0.6.dev0+g1234567
40-
build.hooks.vcs.version-file = "src/mpremote_path/_version.py"
4144
build.targets.wheel.packages = ["src/mpremote_path"]
45+
build.hooks.vcs.version-file = "src/mpremote_path/_version.py"
46+
version.source = "vcs" # Get the version from git, eg: 0.0.6.dev0+g1234567
4247
# Drop the local version part (eg: +g1234567) or pypi will reject package
4348
version.raw-options.local_scheme = "no-local-version"
4449
# A manually triggered github release workflow may generate a new tag
@@ -52,28 +57,6 @@ version.raw-options.git_describe_command = [
5257
"--match", "v*.[0-9][0-9][0-9]",
5358
]
5459

55-
[tool.uv]
56-
dev-dependencies = [
57-
# For development environment, including type checking
58-
"types-pyserial>=3.5", # For type checking pyserial (needed by mpremote)
59-
# For running tests: pytest, pyyaml, requests, tox, mypy, ruff
60-
"pyyaml>=6.0.0", # For logging configuration in tests/
61-
"types-pyyaml>=6.0.0",
62-
"pytest>=8.3.2",
63-
"pytest-cov>=3.0.0",
64-
"mypy>=0.910", # For code type checks: uv run mypy --no-sources mypy src
65-
"ruff>=0.6.7", # For linting: uv run --no-sources ruff format --check src
66-
"tox>=4.0.0",
67-
"tox-uv>=0.3.0", # uv support for tox
68-
"keyring>=25", # For uv publish --keyring-provider=subprocess
69-
# Used by .git/hooks/post-{commit,checkout} to update _version.py:
70-
# uv run --frozen hatch build --hooks-only
71-
"hatch>=1.12.0",
72-
"hatch-vcs>=0.3.0", # For building and updating _version.py
73-
"pre-commit>=2.9.2", # For running ruff and mypy on Python files
74-
"pre-commit-uv>=4.0",
75-
]
76-
7760
[tool.mypy]
7861
files = ["src", "tests"]
7962
exclude = "(^tests/_data.*$|^tests/unix-micropython/.*$)"
@@ -84,14 +67,9 @@ warn_return_any = true
8467
warn_unused_ignores = false
8568

8669
[tool.ruff]
87-
include = ["src/**/*.py"]
88-
exclude = ["_version.py"]
70+
exclude = ["_version.py", "tests/_data", "tests/unix-micropython"]
8971
lint.extend-select = ["I"] # Enable ruffs isort rules (for compat with vscode ruff)
9072

91-
[tool.pytest.ini_options]
92-
minversion = "6.0"
93-
addopts = ["--cov", "--color=yes"]
94-
9573
[tool.coverage]
9674
run.source = ["src"]
9775
run.omit = ["_version.py"]
@@ -101,20 +79,17 @@ append = true
10179
# https://tox.wiki/en/latest/config.html#pyproject-toml-native
10280
[tool.tox] #
10381
env_list = [
104-
"clean", "mypy", "lint", "format",
82+
"clean", "typing", "lint", "format",
10583
"3.9", "3.10", "3.11", "3.12", "3.13"
10684
]
107-
requires = ["tox>=4.19", "tox-uv>=1.13"]
85+
labels = { static = ["clean", "typing", "lint", "format"], test = ["3.13"] }
86+
dependency_groups = ["test"]
10887
env.clean.commands = [["coverage", "erase"]] # Cleanup coverage data
109-
env.clean.deps = ["coverage"]
11088
env.clean.skip_install = true
111-
env.mypy.commands = [["mypy"]]
112-
env.mypy.deps = ["mypy", "types-pyserial", "types-pyyaml"]
89+
env.typing.commands = [["mypy"]]
11390
env.lint.commands = [["ruff", "check"]]
114-
env.lint.deps = ["ruff"]
11591
env.format.commands = [["ruff", "format", "--check"]]
116-
env.format.deps = ["ruff"]
92+
env.3.13.commands = [["pytest", "--cov", {replace = "posargs", extend = true}]]
11793
env_run_base.commands = [["pytest", {replace = "posargs", extend = true}]]
118-
env_run_base.deps = ["pytest", "pytest-cov", "pyyaml"]
11994
env_run_base.package = "editable"
12095
env_run_base.runner = "uv-venv-runner"

0 commit comments

Comments
 (0)