chore: consolidate Ruff configs, add prettier dependancy and updated documentation usage

- Remove per-package Black, Ruff, and MyPy settings in individual pyproject.toml files
- Centralize Ruff configuration in root pyproject.toml under [tool.ruff.lint] with selected ignores
- Add Prettier setup and usage instructions to Development.md
- Include pnpm install instructions for JS/TS dependencies
- Ensure pre-commit hooks enforce Python and JS/TS formatting consistently
This commit is contained in:
Aditya Bavadekar
2025-10-22 02:21:37 +05:30
committed by James Murdza
parent 51ee79a9d2
commit c33517a42d
11 changed files with 138 additions and 149 deletions

View File

@@ -38,7 +38,27 @@ These packages are part of a uv workspace which manages a shared virtual environ
OPENAI_API_KEY=your_openai_key_here
```
4. Open the workspace in VSCode or Cursor:
4. Install Node.js dependencies for Prettier and other scripts:
```bash
# Install pnpm if you don't have it
npm install -g pnpm
# Install all JS/TS dependencies
pnpm install
```
5. Install Python dependencies and workspace packages:
```bash
# First install uv if you don't have it
pip install uv
# Then install all Python dependencies
uv sync
```
6. Open the workspace in VSCode or Cursor:
```bash
# For Cua Python development
@@ -48,7 +68,13 @@ These packages are part of a uv workspace which manages a shared virtual environ
code .vscode/lume.code-workspace
```
5. Install Pre-commit hooks ([see below](#pre-commit-hook)):
7. Install Pre-commit hooks:
This ensures code formatting and validation run automatically on each commit.
```bash
uv run pre-commit install
```
Using the workspace file is strongly recommended as it:
@@ -57,19 +83,6 @@ Using the workspace file is strongly recommended as it:
- Enables debugging configurations
- Maintains consistent settings across packages
### Pre-commit Hook Installation
Pre-commit hooks are scripts that run automatically before each commit to ensure code quality and consistency.
To install the hooks:
```bash
# First, ensure dependencies are installed (only needed once)
uv sync
# Then install the pre-commit hooks
uv run pre-commit install
```
## Lume Development
Refer to the [Lume README](./libs/lume/Development.md) for instructions on how to develop the Lume CLI.
@@ -149,23 +162,34 @@ line-length = 100
target-version = ["py311"]
[tool.ruff]
fix = true
line-length = 100
target-version = "py311"
[tool.ruff.lint]
select = ["E", "F", "B", "I"]
ignore = [
"E501", "E402", "I001", "I002", "B007", "B023", "B024", "B027", "B028",
"B904", "B905", "E711", "E712", "E722", "E731", "F401", "F403", "F405",
"F811", "F821", "F841"
]
fix = true
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
strict = true
python_version = "3.11"
ignore_missing_imports = true
disallow_untyped_defs = true
check_untyped_defs = true
warn_return_any = true
disallow_untyped_defs = true
ignore_missing_imports = true
python_version = "3.11"
show_error_codes = true
strict = true
warn_return_any = true
warn_unused_ignores = false
[tool.isort]
profile = "black"
```
#### Key Formatting Rules
@@ -269,6 +293,52 @@ uv run prettier --check "**/*.{ts,tsx,js,jsx,json,md,yaml,yml}"
node ./scripts/typescript-typecheck.js
```
### JavaScript / TypeScript Formatting (Prettier)
The project uses **Prettier** to ensure consistent formatting across all JS/TS/JSON/Markdown/YAML files.
#### Installation
All Node.js dependencies are managed via `pnpm`. Make sure you have run:
```bash
# Install pnpm if you don't have it
npm install -g pnpm
# Install project dependencies
pnpm install
```
This installs Prettier and other JS/TS dependencies defined in `package.json`.
#### Usage
- **Check formatting** (without making changes):
```bash
pnpm prettier:check
```
- **Automatically format files**:
```bash
pnpm prettier:format
```
#### Type Checking (TypeScript)
- Run the TypeScript type checker:
```bash
node ./scripts/typescript-typecheck.js
```
#### VSCode Integration
- The workspace config ensures Prettier is used automatically for JS/TS/JSON/Markdown/YAML files.
- Recommended extension: Prettier Code Formatter
- Ensure `editor.formatOnSave` is enabled in VSCode for automatic formatting.
### Swift Code (Lume)
For Swift code in the `libs/lume` directory:

View File

@@ -108,4 +108,4 @@ constraint-dependencies = ["fastrtc>0.43.0", "mlx-audio>0.2.3"]
distribution = true
[tool.pdm.build]
includes = ["agent/"]
includes = ["agent/"]

View File

@@ -67,23 +67,4 @@ dev = [
]
[tool.pdm.scripts]
api = "python -m computer_server"
[tool.ruff]
line-length = 100
target-version = "py310"
select = ["E", "F", "B", "I"]
fix = true
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
strict = true
python_version = "3.10"
ignore_missing_imports = true
disallow_untyped_defs = true
check_untyped_defs = true
warn_return_any = true
show_error_codes = true
warn_unused_ignores = false
api = "python -m computer_server"

View File

@@ -44,29 +44,6 @@ distribution = true
includes = ["computer/"]
source-includes = ["tests/", "README.md", "LICENSE"]
[tool.black]
line-length = 100
target-version = ["py311"]
[tool.ruff]
line-length = 100
target-version = "py311"
select = ["E", "F", "B", "I"]
fix = true
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
strict = true
python_version = "3.11"
ignore_missing_imports = true
disallow_untyped_defs = true
check_untyped_defs = true
warn_return_any = true
show_error_codes = true
warn_unused_ignores = false
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]

View File

@@ -24,34 +24,11 @@ distribution = true
includes = ["core/"]
source-includes = ["tests/", "README.md", "LICENSE"]
[tool.black]
line-length = 100
target-version = ["py311"]
[tool.ruff]
line-length = 100
target-version = "py311"
select = ["E", "F", "B", "I"]
fix = true
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
strict = true
python_version = "3.11"
ignore_missing_imports = true
disallow_untyped_defs = true
check_untyped_defs = true
warn_return_any = true
show_error_codes = true
warn_unused_ignores = false
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
python_files = "test_*.py"
python_files = "test_*.py"
[dependency-groups]
dev = [
"pytest>=8.3.5",
]
]

View File

@@ -27,14 +27,4 @@ distribution = true
dev = [
"black>=23.9.1",
"ruff>=0.0.292",
]
[tool.black]
line-length = 100
target-version = ["py311"]
[tool.ruff]
line-length = 100
target-version = "py311"
select = ["E", "F", "B", "I"]
fix = true
]

View File

@@ -41,29 +41,6 @@ dev = [
"pytest>=7.0.0",
]
[tool.black]
line-length = 100
target-version = ["py311"]
[tool.ruff]
fix = true
line-length = 100
select = ["B", "E", "F", "I"]
target-version = "py311"
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
check_untyped_defs = true
disallow_untyped_defs = true
ignore_missing_imports = true
python_version = "3.11"
show_error_codes = true
strict = true
warn_return_any = true
warn_unused_ignores = false
[tool.pytest.ini_options]
asyncio_mode = "auto"
python_files = "test_*.py"
@@ -71,4 +48,4 @@ testpaths = ["tests"]
[tool.pdm.build]
includes = ["pylume/"]
source-includes = ["LICENSE", "README.md", "tests/"]
source-includes = ["LICENSE", "README.md", "tests/"]

View File

@@ -52,30 +52,7 @@ src-layout = false
includes = ["som/"]
source-includes = ["tests/", "README.md", "LICENSE"]
[tool.black]
line-length = 100
target-version = ["py311"]
[tool.ruff]
line-length = 100
target-version = "py311"
select = ["E", "F", "B", "I"]
fix = true
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
strict = true
python_version = "3.11"
ignore_missing_imports = true
disallow_untyped_defs = true
check_untyped_defs = true
warn_return_any = true
show_error_codes = true
warn_unused_ignores = false
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
python_files = "test_*.py"
python_files = "test_*.py"

9
package.json Normal file
View File

@@ -0,0 +1,9 @@
{
"scripts": {
"prettier:check": "prettier --check '**/*.{ts,tsx,js,jsx,json,md,yaml,yml}'",
"prettier:format": "prettier --write '**/*.{ts,tsx,js,jsx,json,md,yaml,yml}'"
},
"devDependencies": {
"prettier": "^3.6.2"
}
}

24
pnpm-lock.yaml generated Normal file
View File

@@ -0,0 +1,24 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
devDependencies:
prettier:
specifier: ^3.6.2
version: 3.6.2
packages:
prettier@3.6.2:
resolution:
{
integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==
}
engines: { node: '>=14' }
hasBin: true
snapshots:
prettier@3.6.2: {}

View File

@@ -75,9 +75,16 @@ target-version = ["py311"]
[tool.ruff]
fix = true
line-length = 100
select = ["B", "E", "F", "I"]
target-version = "py311"
[tool.ruff.lint]
select = ["E", "F", "B", "I"]
ignore = [
"E501", "E402", "I001", "I002", "B007", "B023", "B024", "B027", "B028",
"B904", "B905", "E711", "E712", "E722", "E731", "F401", "F403", "F405",
"F811", "F821", "F841"
]
[tool.ruff.format]
docstring-code-format = true