Skip to content

Commit 8ea5868

Browse files
CopilotArchmonger
andcommitted
Enhance GitHub Copilot instructions with django-dbbackup best practices
Co-authored-by: Archmonger <[email protected]>
1 parent 9f44070 commit 8ea5868

File tree

1 file changed

+128
-28
lines changed

1 file changed

+128
-28
lines changed

.github/copilot-instructions.md

Lines changed: 128 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ ReactPy is a Python library for building user interfaces without JavaScript. It
44

55
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
66

7+
**IMPORTANT**: This package uses modern Python tooling with Hatch for all development workflows. Always use Hatch commands for development tasks.
8+
9+
**BUG INVESTIGATION**: When investigating whether a bug was already resolved in a previous version, always prioritize searching through `docs/source/about/changelog.rst` first before using Git history. Only search through Git history when no relevant changelog entries are found.
10+
711
## Working Effectively
812

913
### Bootstrap, Build, and Test the Repository
@@ -40,7 +44,8 @@ pip install flask sanic tornado
4044
- `hatch build --clean` -- takes 10 seconds. NEVER CANCEL. Set timeout to 60+ minutes for safety.
4145

4246
**Run Python Tests:**
43-
- `hatch test` -- takes 10-30 seconds for basic tests. NEVER CANCEL. Set timeout to 60+ minutes for full test suite.
47+
- `hatch test` -- takes 10-30 seconds for basic tests. NEVER CANCEL. Set timeout to 60+ minutes for full test suite. **All tests must always pass - failures are never expected or allowed.**
48+
- `hatch test --cover` -- run tests with coverage reporting (used in CI)
4449
- `hatch test -k test_name` -- run specific tests
4550
- `hatch test tests/test_config.py` -- run specific test files
4651
- Note: Some tests require Playwright browser automation and may fail in headless environments
@@ -57,6 +62,11 @@ pip install flask sanic tornado
5762
- `hatch run javascript:fix` -- Format JavaScript code
5863
- `hatch run javascript:test` -- Run JavaScript tests (note: may fail in headless environments due to DOM dependencies)
5964

65+
**Interactive Development Shell:**
66+
- `hatch shell` -- Enter an interactive shell environment with all dependencies installed
67+
- `hatch shell default` -- Enter the default development environment
68+
- Use the shell for interactive debugging and development tasks
69+
6070
## Validation
6171

6272
Always manually validate any new code changes through these steps:
@@ -125,39 +135,44 @@ print(f"✓ Hook-based component: {type(counter)}")
125135
```
126136

127137
**Always run these validation steps before completing work:**
128-
- `hatch fmt --check` -- Ensure code is properly formatted
129-
- `hatch run python:type_check` -- Ensure no type errors
130-
- `hatch run javascript:check` -- Ensure JavaScript passes linting
138+
- `hatch fmt --check` -- Ensure code is properly formatted (never expected to fail)
139+
- `hatch run python:type_check` -- Ensure no type errors (never expected to fail)
140+
- `hatch run javascript:check` -- Ensure JavaScript passes linting (never expected to fail)
131141
- Test basic component creation and rendering as shown above
132142
- Test server creation if working on server-related features
143+
- Run relevant tests with `hatch test` -- **All tests must always pass - failures are never expected or allowed**
133144

134145
**Integration Testing:**
135146
- ReactPy can be deployed with FastAPI, Flask, Sanic, Tornado via ASGI
136147
- For browser testing, Playwright is used but requires additional setup
137148
- Test component VDOM rendering directly when browser testing isn't available
138149
- Validate that JavaScript builds are included in Python package after changes
139150

140-
## Repository Structure
151+
## Repository Structure and Navigation
141152

142153
### Key Directories:
143154
- `src/reactpy/` -- Main Python package source code
155+
- `core/` -- Core ReactPy functionality (components, hooks, VDOM)
156+
- `web/` -- Web module management and exports
157+
- `executors/` -- Server integration modules (ASGI, etc.)
158+
- `testing/` -- Testing utilities and fixtures
159+
- `pyscript/` -- PyScript integration
160+
- `static/` -- Bundled JavaScript files
161+
- `_html.py` -- HTML element factory functions
144162
- `src/js/` -- JavaScript packages that get bundled with Python
163+
- `packages/event-to-object/` -- Event serialization package
164+
- `packages/@reactpy/client/` -- Client-side React integration
165+
- `packages/@reactpy/app/` -- Application framework
145166
- `src/build_scripts/` -- Build automation scripts
146-
- `tests/` -- Python test suite
147-
- `docs/` -- Documentation source (currently transitioning to MkDocs)
167+
- `tests/` -- Python test suite with comprehensive coverage
168+
- `docs/` -- Documentation source (MkDocs-based, transitioning setup)
148169

149170
### Important Files:
150-
- `pyproject.toml` -- Python project configuration and build scripts
171+
- `pyproject.toml` -- Python project configuration and Hatch environments
151172
- `src/js/package.json` -- JavaScript development dependencies
152-
- `src/js/packages/` -- Individual JavaScript packages
153173
- `tests/conftest.py` -- Test configuration and fixtures
154-
155-
### Key Components:
156-
- `src/reactpy/core/` -- Core ReactPy functionality (components, hooks, VDOM)
157-
- `src/reactpy/web/` -- Web module management and exports
158-
- `src/reactpy/widgets/` -- Built-in UI components
159-
- `src/reactpy/pyscript/` -- PyScript integration
160-
- `src/reactpy/_html.py` -- HTML element factory functions
174+
- `docs/source/about/changelog.rst` -- Version history and changes
175+
- `.github/workflows/check.yml` -- CI/CD pipeline configuration
161176

162177
## Common Tasks
163178

@@ -169,14 +184,6 @@ print(f"✓ Hook-based component: {type(counter)}")
169184
- Type checking: 10 seconds
170185
- Full CI pipeline: 5-10 minutes
171186

172-
### Development Workflow:
173-
1. Make code changes
174-
2. Run `hatch fmt` to format code (~1 second)
175-
3. Run `hatch run python:type_check` for type checking (~10 seconds)
176-
4. Run `hatch run javascript:check` if JavaScript was modified (~10 seconds)
177-
5. Run relevant tests with `hatch test`
178-
6. Validate component functionality manually using validation tests above
179-
180187
### Running ReactPy Applications:
181188

182189
**ASGI Standalone (Recommended):**
@@ -229,6 +236,60 @@ def my_component(initial_value=0):
229236
- Built JavaScript gets bundled into `src/reactpy/static/`
230237
- Always rebuild JavaScript after changes: `hatch run javascript:build`
231238

239+
## Common Hatch Commands
240+
241+
The following are key commands for daily development:
242+
243+
### Development Commands
244+
```bash
245+
hatch test # Run all tests (**All tests must always pass**)
246+
hatch test --cover # Run tests with coverage (used in CI)
247+
hatch test -k test_name # Run specific tests
248+
hatch fmt # Format code with all formatters
249+
hatch fmt --check # Check formatting without changes
250+
hatch run python:type_check # Run Python type checker
251+
hatch run javascript:build # Build JavaScript packages (15 seconds)
252+
hatch run javascript:check # Lint JavaScript code (10 seconds)
253+
hatch run javascript:fix # Format JavaScript code
254+
hatch build --clean # Build Python package (10 seconds)
255+
```
256+
257+
### Environment Management
258+
```bash
259+
hatch env show # Show all environments
260+
hatch shell # Enter default shell
261+
hatch shell default # Enter development shell
262+
```
263+
264+
### Build Timing Expectations
265+
- **NEVER CANCEL**: All commands complete within 60 seconds in normal operation
266+
- **JavaScript build**: 15 seconds (hatch run javascript:build)
267+
- **Python package build**: 10 seconds (hatch build --clean)
268+
- **Python linting**: 1 second (hatch fmt)
269+
- **JavaScript linting**: 10 seconds (hatch run javascript:check)
270+
- **Type checking**: 10 seconds (hatch run python:type_check)
271+
- **Unit tests**: 10-30 seconds (varies by test selection)
272+
- **Full CI pipeline**: 5-10 minutes
273+
274+
## Development Workflow
275+
276+
Follow this step-by-step process for effective development:
277+
278+
1. **Bootstrap environment**: Ensure you have Python 3.9+ and run `pip install hatch`
279+
2. **Make your changes** to the codebase
280+
3. **Run formatting**: `hatch fmt` to format code (~1 second)
281+
4. **Run type checking**: `hatch run python:type_check` for type checking (~10 seconds)
282+
5. **Run JavaScript linting** (if JavaScript was modified): `hatch run javascript:check` (~10 seconds)
283+
6. **Run relevant tests**: `hatch test` with specific test selection if needed. **All tests must always pass - failures are never expected or allowed.**
284+
7. **Validate component functionality** manually using validation tests above
285+
8. **Build JavaScript** (if modified): `hatch run javascript:build` (~15 seconds)
286+
9. **Update documentation** when making changes to Python source code (required)
287+
10. **Add changelog entry** for all significant changes to `docs/source/about/changelog.rst`
288+
289+
**IMPORTANT**: Documentation must be updated whenever changes are made to Python source code. This is enforced as part of the development workflow.
290+
291+
**IMPORTANT**: Significant changes must always include a changelog entry in `docs/source/about/changelog.rst` under the appropriate version section.
292+
232293
## Troubleshooting
233294

234295
### Build Issues:
@@ -255,14 +316,53 @@ def my_component(initial_value=0):
255316
- For Flask integration: `pip install flask` (requires additional backend package)
256317
- For development servers, use ReactPy ASGI standalone for simplest setup
257318

319+
## Package Dependencies
320+
321+
Modern dependency management via pyproject.toml:
322+
323+
**Core Runtime Dependencies:**
324+
- `fastjsonschema >=2.14.5` -- JSON schema validation
325+
- `requests >=2` -- HTTP client library
326+
- `lxml >=4` -- XML/HTML processing
327+
- `anyio >=3` -- Async I/O abstraction
328+
- `typing-extensions >=3.10` -- Type hints backport
329+
330+
**Optional Dependencies (install via extras):**
331+
- `asgi` -- ASGI server support: `orjson`, `asgiref`, `asgi-tools`, `servestatic`, `pip`
332+
- `jinja` -- Template integration: `jinja2-simple-tags`, `jinja2 >=3`
333+
- `uvicorn` -- ASGI server: `uvicorn[standard]`
334+
- `testing` -- Browser automation: `playwright`
335+
- `all` -- All optional dependencies combined
336+
337+
**Development Dependencies (managed by Hatch):**
338+
- **JavaScript tooling**: Bun runtime for building packages
339+
- **Python tooling**: Hatch environments handle all dev dependencies automatically
340+
258341
## CI/CD Information
259342

260343
The repository uses GitHub Actions with these key jobs:
261-
- `test-python-coverage` -- Python test coverage
262-
- `lint-python` -- Python linting and type checking
263-
- `test-python` -- Cross-platform Python testing
344+
- `test-python-coverage` -- Python test coverage with `hatch test --cover`
345+
- `lint-python` -- Python linting and type checking via `hatch fmt --check` and `hatch run python:type_check`
346+
- `test-python` -- Cross-platform Python testing across Python 3.10-3.13 and Ubuntu/macOS/Windows
264347
- `lint-javascript` -- JavaScript linting and type checking
265348

266349
The CI workflow is defined in `.github/workflows/check.yml` and uses the reusable workflow in `.github/workflows/.hatch-run.yml`.
267350

268-
Always ensure your changes pass local validation before pushing, as the CI pipeline will run the same checks.
351+
**Build Matrix:**
352+
- **Python versions**: 3.10, 3.11, 3.12, 3.13
353+
- **Operating systems**: Ubuntu, macOS, Windows
354+
- **Test execution**: Hatch-managed environments ensure consistency across platforms
355+
356+
Always ensure your changes pass local validation before pushing, as the CI pipeline will run the same checks.
357+
358+
## Important Notes
359+
360+
- **This is a Python-to-JavaScript bridge library**, not a traditional web framework - it enables React-like components in Python
361+
- **Component rendering uses VDOM** - components return virtual DOM objects that get serialized to JavaScript
362+
- **All builds and tests run quickly** - if something takes more than 60 seconds, investigate the issue
363+
- **Hatch environments provide full isolation** - no need to manage virtual environments manually
364+
- **JavaScript packages are bundled into Python** - the build process combines JS and Python into a single distribution
365+
- **Browser automation tests may fail in headless environments** - this is expected behavior for Playwright tests
366+
- **Documentation updates are required** when making changes to Python source code
367+
- **Always update this file** when making changes to the development workflow, build process, or repository structure
368+
- **All tests must always pass** - failures are never expected or allowed in a healthy development environment

0 commit comments

Comments
 (0)