Skip to content

Commit 5310451

Browse files
authored
Merge branch 'main' into opposite-lynx
2 parents 034f280 + eb6df9a commit 5310451

File tree

88 files changed

+6325
-1580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+6325
-1580
lines changed

.github/actions/build-vsix/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222
using: 'composite'
2323
steps:
2424
- name: Install Node
25-
uses: actions/setup-node@v4
25+
uses: actions/setup-node@v6
2626
with:
2727
node-version: ${{ inputs.node_version }}
2828
cache: 'npm'
@@ -93,7 +93,7 @@ runs:
9393
VSIX_NAME: ${{ inputs.vsix_name }}
9494

9595
- name: Upload VSIX
96-
uses: actions/upload-artifact@v4
96+
uses: actions/upload-artifact@v6
9797
with:
9898
name: ${{ inputs.artifact_name }}
9999
path: ${{ inputs.vsix_name }}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
applyTo: 'python_files/**'
3+
description: Guide for running and fixing Python quality checks (Ruff and Pyright) that run in CI
4+
---
5+
6+
# Python Quality Checks — Ruff and Pyright
7+
8+
Run the same Python quality checks that run in CI. All checks target `python_files/` and use config from `python_files/pyproject.toml`.
9+
10+
## Commands
11+
12+
```bash
13+
npm run check-python # Run both Ruff and Pyright
14+
npm run check-python:ruff # Linting and formatting only
15+
npm run check-python:pyright # Type checking only
16+
```
17+
18+
## Fixing Ruff Errors
19+
20+
**Auto-fix most issues:**
21+
22+
```bash
23+
cd python_files
24+
python -m ruff check . --fix
25+
python -m ruff format
26+
npm run check-python:ruff # Verify
27+
```
28+
29+
**Manual fixes:**
30+
31+
- Ruff shows file, line number, rule code (e.g., `F841`), and description
32+
- Open the file, read the error, fix the code
33+
- Common: line length (100 char max), import sorting, unused variables
34+
35+
## Fixing Pyright Errors
36+
37+
**Common patterns and fixes:**
38+
39+
- **Undefined variable/import**: Add the missing import
40+
- **Type mismatch**: Correct the type or add type annotations
41+
- **Missing return type**: Add `-> ReturnType` to function signatures
42+
```python
43+
def my_function() -> str: # Add return type
44+
return "result"
45+
```
46+
47+
**Verify:**
48+
49+
```bash
50+
npm run check-python:pyright
51+
```
52+
53+
## Configuration
54+
55+
- **Ruff**: Line length 100, Python 3.9+, 40+ rule families (flake8, isort, pyupgrade, etc.)
56+
- **Pyright**: Version 1.1.308 (or whatever is found in the environment), ignores `lib/` and 15+ legacy files
57+
- Config: `python_files/pyproject.toml` sections `[tool.ruff]` and `[tool.pyright]`
58+
59+
## Troubleshooting
60+
61+
**"Module not found" in Pyright**: Install dependencies
62+
63+
```bash
64+
python -m pip install --upgrade -r build/test-requirements.txt
65+
nox --session install_python_libs
66+
```
67+
68+
**Import order errors**: Auto-fix with `ruff check . --fix`
69+
70+
**Type errors in ignored files**: Legacy files in `pyproject.toml` ignore list—fix if working on them
71+
72+
## When Writing Tests
73+
74+
**Always format your test files before committing:**
75+
76+
```bash
77+
cd python_files
78+
ruff format tests/ # Format all test files
79+
# or format specific files:
80+
ruff format tests/unittestadapter/test_utils.py
81+
```
82+
83+
**Best practice workflow:**
84+
85+
1. Write your test code
86+
2. Run `ruff format` on the test files
87+
3. Run the tests to verify they pass
88+
4. Run `npm run check-python` to catch any remaining issues
89+
90+
This ensures your tests pass both functional checks and quality checks in CI.
91+
92+
## Learnings
93+
94+
- Always run `npm run check-python` before pushing to catch CI failures early (1)
95+
- Use `ruff check . --fix` to auto-fix most linting issues before manual review (1)
96+
- Pyright version must match CI (1.1.308) to avoid inconsistent results between local and CI runs (1)
97+
- Always run `ruff format` on test files after writing them to avoid formatting CI failures (1)

0 commit comments

Comments
 (0)