Skip to content

Commit e43406e

Browse files
authored
Merge pull request #40 from TATP-233/chore/dev-tooling-upgrade
Chore/dev tooling upgrade
2 parents 41db8fa + 9307216 commit e43406e

33 files changed

Lines changed: 146 additions & 58 deletions

‎.github/workflows/ci.yml‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
6+
paths-ignore:
7+
- "*.md"
8+
- "CONTRIBUTING.md"
9+
- "CLAUDE.md"
10+
- "LICENSE"
611
pull_request:
7-
branches: [ main ]
12+
branches: [main]
13+
paths-ignore:
14+
- "*.md"
15+
- "CONTRIBUTING.md"
16+
- "CLAUDE.md"
17+
- "LICENSE"
18+
19+
env:
20+
UV_FROZEN: "1"
821

922
jobs:
1023
lint:
1124
runs-on: ubuntu-latest
1225
steps:
1326
- uses: actions/checkout@v4
14-
- uses: astral-sh/setup-uv@v5
27+
- uses: astral-sh/setup-uv@v6
1528
with:
1629
enable-cache: true
1730
- name: Lint with ruff
@@ -23,25 +36,28 @@ jobs:
2336
runs-on: ubuntu-latest
2437
steps:
2538
- uses: actions/checkout@v4
26-
- uses: astral-sh/setup-uv@v5
39+
- uses: astral-sh/setup-uv@v6
2740
with:
2841
enable-cache: true
2942
- name: Install dependencies
3043
run: uv sync --extra dev
31-
- name: Type check
44+
- name: mypy
3245
run: uv run mypy unilab
46+
- name: pyright
47+
run: uv run pyright
3348

3449
test:
3550
strategy:
3651
matrix:
3752
os: [ubuntu-latest, macos-latest]
38-
python-version: ['3.10', '3.11', '3.12']
53+
python-version: ['3.10', '3.11', '3.12', '3.13']
3954
runs-on: ${{ matrix.os }}
4055
steps:
4156
- uses: actions/checkout@v4
42-
- uses: astral-sh/setup-uv@v5
57+
- uses: astral-sh/setup-uv@v6
4358
with:
4459
enable-cache: true
60+
python-version: ${{ matrix.python-version }}
4561
- name: Install dependencies (Linux)
4662
if: runner.os == 'Linux'
4763
run: |

‎.pre-commit-config.yaml‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.8.4
3+
rev: v0.14.14
44
hooks:
55
- id: ruff
66
args: [--fix]
77
- id: ruff-format
88

9-
- repo: https://github.com/pre-commit/mirrors-mypy
10-
rev: v1.14.0
9+
- repo: https://github.com/RobertCraigie/pyright-python
10+
rev: v1.1.408
1111
hooks:
12-
- id: mypy
13-
additional_dependencies: [types-all]
14-
args: [--ignore-missing-imports]
12+
- id: pyright

‎CLAUDE.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ uv sync --extra dev --extra cu124
3030

3131
```bash
3232
make format # Format and lint code (ruff format + ruff check --fix)
33-
make type # Type check with mypy
33+
make type # Type check with mypy + pyright
3434
make check # make format && make type
3535
make test # Run all non-slow tests (default)
3636
make test-cov # Run non-slow tests with coverage report
@@ -47,6 +47,7 @@ uv run ruff check --fix
4747

4848
# Type check
4949
uv run mypy unilab
50+
uv run pyright
5051

5152
# Test (non-slow)
5253
uv run pytest -m "not slow"

‎CONTRIBUTING.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
## 开发规范
1010

1111
- **Always use `uv run`**,不要直接使用 `python`
12-
- 提交前必须通过 `make check`(ruff lint + mypy)
12+
- 提交前必须通过 `make check`(ruff lint + mypy + pyright)
1313

1414
## 常用命令
1515

1616
```bash
1717
make format # ruff format + ruff check --fix
18-
make type # mypy unilab
18+
make type # mypy unilab + pyright
1919
make check # format + type(提交前必跑)
2020
make test # 非 slow 单元测试
2121
make test-cov # 非 slow 测试 + 覆盖率报告
@@ -94,12 +94,14 @@ Push / PR 到 `main` 时自动触发三个 job:
9494
| Job | 内容 | 失败即阻断 |
9595
|-----|------|-----------|
9696
| `lint` | `ruff check` + `ruff format --check` | ✅ |
97-
| `typecheck` | `mypy unilab` | ✅ |
98-
| `test` | `pytest -m "not slow" --cov` (matrix: ubuntu+macos × py3.10/3.11/3.12) | ✅ |
97+
| `typecheck` | `mypy unilab` + `pyright` | ✅ |
98+
| `test` | `pytest -m "not slow" --cov` (matrix: ubuntu+macos × py3.10/3.11/3.12/3.13) | ✅ |
99+
100+
纯文档改动(`*.md`、`LICENSE`)不触发 CI。
99101

100102
## Pull Request 流程
101103

102-
1. 本地运行 `make check` 确保 lint/mypy 通过
104+
1. 本地运行 `make check` 确保 lint/mypy/pyright 通过
103105
2. 本地运行 `make test` 确保单元测试通过
104106
3. 若改动了 IPC / Runner / Config,补充或更新对应测试
105107
4. 提交 PR 到 `main` 分支,等待 CI 全绿

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ format:
1010
.PHONY: type
1111
type:
1212
uv run mypy unilab
13+
uv run pyright
1314

1415
.PHONY: check
1516
check: format type

‎benchmark/benchmark_postprocess.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import mlx.core as mx
1515
import numpy as np
1616
import torch
17-
1817
from unilab.base import registry
1918

2019
try:

‎pyproject.toml‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "unilab"
77
version = "0.1.0"
88
description = "Universal Lab for Robot Learning"
99
readme = "README.md"
10-
requires-python = ">=3.10,<3.13"
10+
requires-python = ">=3.10,<3.14"
1111
dependencies = [
1212
"numpy",
1313
"torch",
@@ -28,14 +28,14 @@ dependencies = [
2828
]
2929

3030
[project.optional-dependencies]
31-
dev = ["pytest", "pytest-cov", "ruff", "mypy"]
31+
dev = ["pytest", "pytest-cov", "ruff", "mypy", "pyright>=1.1.408"]
3232
cu124 = [
3333
# Keep compatibility with documented Linux CUDA installation command.
3434
]
3535
motrix = ["motrixsim==0.6.0"]
3636

3737
[dependency-groups]
38-
dev = ["pytest", "pytest-cov", "ruff", "mypy"]
38+
dev = ["pytest", "pytest-cov", "ruff", "mypy", "pyright>=1.1.408"]
3939

4040
[[tool.uv.index]]
4141
name = "test-pypi"
@@ -51,6 +51,7 @@ packages = ["unilab"]
5151
[tool.ruff]
5252
line-length = 100
5353
target-version = "py310"
54+
src = ["unilab"]
5455

5556
[tool.ruff.lint]
5657
select = ["E", "F", "I", "N", "W"]
@@ -83,7 +84,24 @@ addopts = "--tb=short"
8384

8485
[tool.coverage.run]
8586
source = ["unilab"]
86-
omit = ["unilab/algos/torch/rsl_rl/*"]
87+
omit = ["*/rsl_rl/*"]
8788

8889
[tool.coverage.report]
8990
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
91+
92+
[tool.pyright]
93+
pythonVersion = "3.10"
94+
venvPath = "."
95+
venv = ".venv"
96+
include = ["unilab"]
97+
exclude = [
98+
"unilab/algos/torch/rsl_rl/", # vendored third-party
99+
"unilab/algos/mlx/", # MLX stubs incomplete, macOS-only
100+
"unilab/algos/torch/common/ane_*", # Apple Neural Engine, macOS-only
101+
"unilab/base/backend/", # mujoco-uni stubs mismatch; optional backends
102+
"unilab/envs/", # mujoco-uni internal API, stubs mismatch
103+
"unilab/utils/render_many.py", # direct mujoco C bindings
104+
"unilab/utils/hardware_monitor.py", # optional pynvml/psutil deps
105+
]
106+
reportMissingImports = "warning"
107+
reportMissingModuleSource = "none"

‎scripts/train_appo.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def play_appo(args, rl_cfg):
4848
import numpy as np
4949
from rsl_rl.utils import resolve_callable
5050
from tensordict import TensorDict
51-
5251
from unilab.base import registry
5352
from unilab.utils import render_many
5453
from unilab.utils.rsl_rl_compat import convert_config_v3_to_v4, is_rsl_rl_v4, is_rsl_rl_v5

‎scripts/train_mlx_ppo.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def play_mlx_ppo(args, cfg, dtype, use_fp16, resolved_sim_backend, task_log_root
159159
"""Play mode for MLX PPO."""
160160
import mlx.core as mx
161161
import numpy as np
162-
163162
from unilab.base import registry
164163

165164
play_model_dtype = mx.float32 if use_fp16 else dtype

‎scripts/train_offpolicy.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def play_offpolicy(algo_name: str, args, cfg) -> None:
212212
import mediapy as media
213213
import numpy as np
214214
import torch
215-
216215
from unilab.base import registry
217216
from unilab.utils import render_many
218217
from unilab.utils.algo_utils import build_actor

0 commit comments

Comments
 (0)