一键导入
pre-commit-check
// Use before committing or creating a PR for EmbodiChain to verify code style, headers, annotations, exports, and docstrings pass CI checks
// Use before committing or creating a PR for EmbodiChain to verify code style, headers, annotations, exports, and docstrings pass CI checks
Use when adding a new observation, event, reward, action, dataset, or randomization functor to an EmbodiChain environment
Use when adding a new observation, event, reward, action, dataset, or randomization functor to an EmbodiChain environment
Use when creating a new task environment for EmbodiChain, including expert demonstration tasks, RL tasks or any EmbodiedEnv subclass
Use when writing tests for EmbodiChain modules, including observation functors, reward functors, solvers, sensors, environments, or any Python module
Write benchmark scripts for EmbodiChain modules following project conventions
Create a pull request for EmbodiChain following the project's PR template and conventions, including selecting proper GitHub repository labels
| name | pre-commit-check |
| description | Use before committing or creating a PR for EmbodiChain to verify code style, headers, annotations, exports, and docstrings pass CI checks |
Run all local checks that the CI pipeline enforces, catching issues before pushing.
.py filesgit diff --name-only HEAD
git diff --name-only --cached
git status --short
Collect all changed/added .py files.
This is the first CI gate and will cause immediate failure:
black --check --diff --color ./
If it fails, run black . and review the formatting changes.
Every .py file must begin with the 15-line copyright block. For each changed/new .py file, verify the first line is:
# ----------------------------------------------------------------------------
The full header template:
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
from __future__ import annotationsEvery .py file must have this import (after the header, before other imports). This enables A | B syntax and forward references.
__all__ in Public ModulesFor any new or modified module under embodichain/, verify it defines __all__ listing all public symbols. Example:
__all__ = ["MyClass", "my_function"]
Skip this check for __init__.py files that only re-export via from . import *.
For any new public function, class, or method:
Args: section if it takes parametersReturns: section if it returns a value.. attention:: or .. tip:: directives for non-obvious behaviorFor any new public API:
A | B over Union[A, B]TYPE_CHECKING guard for imports that would cause circular dependencies@configclass UsageFor any new configuration class:
@configclass decorator (not bare @dataclass)from dataclasses import MISSING for required fieldsembodichain.utils import configclassFor any new public module or function:
tests/<subpackage>/test_<module>.pyOutput a pass/fail summary:
Pre-Commit Check Results
========================
[PASS] Black formatting
[PASS] Apache 2.0 headers (5/5 files)
[FAIL] from __future__ import annotations — missing in: foo.py
[PASS] __all__ exports
[PASS] Docstrings on public APIs
[PASS] Type annotations
[PASS] @configclass usage
[WARN] Missing tests for: bar.py
Fix the above issues before committing.
The project's CI pipeline (.github/workflows/main.yml) runs:
black --check --diff --color ./pytest testsThis skill covers items 1 and 2 locally. Docs build is heavier and typically only needed for documentation changes.
| Mistake | Fix |
|---|---|
Running black on only one file | Run black . on the whole project — CI checks everything |
| Forgetting test Apache header | Test files also need the 15-line copyright block |
Using Union[A, B] | Use A | B (with from __future__ import annotations) |
Using bare @dataclass | Use @configclass from embodichain.utils |
Missing __all__ in new module | Add __all__ with all public symbols |
| Check | Command/Method |
|---|---|
| Black formatting | black --check --diff --color ./ |
| Auto-fix formatting | black . |
| Header check | Verify first line is # ---...--- |
__future__ import | Grep for from __future__ import annotations |
__all__ export | Grep for __all__ in module |
| Run tests | pytest tests/<path> |