|
| 1 | +# GitHub Copilot Instructions |
| 2 | + |
| 3 | +This document provides guidelines and best practices for using GitHub Copilot in the `osparc-simcore` repository and other Python and Node.js projects. |
| 4 | + |
| 5 | +## General Guidelines |
| 6 | + |
| 7 | +1. **Test-Driven Development**: Write unit tests for all new functions and features. Use `pytest` for Python and appropriate testing frameworks for Node.js. |
| 8 | +2. **Environment Variables**: Use [Environment Variables Guide](../docs/env-vars.md) for configuration. Avoid hardcoding sensitive information. |
| 9 | +3. **Documentation**: Prefer self-explanatory code; add documentation only if explicitly requested by the developer. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## 🛠️Coding Instructions for Python in This Repository |
| 14 | + |
| 15 | +Follow these rules **strictly** when generating Python code: |
| 16 | + |
| 17 | +### 1. Python Version |
| 18 | + |
| 19 | +* Use Python 3.11: Ensure all code uses features and syntax compatible with Python 3.11. |
| 20 | + |
| 21 | +### 2. **Type Annotations** |
| 22 | + |
| 23 | +* Always use full type annotations for all functions and class attributes. |
| 24 | +* ❗ **Exception**: Do **not** add return type annotations in `test_*` functions. |
| 25 | + |
| 26 | +### 3. **Code Style & Formatting** |
| 27 | + |
| 28 | +* Follow [Python Coding Conventions](../docs/coding-conventions.md) **strictly**. |
| 29 | +* Format code with `black`. |
| 30 | +* Lint code with `ruff` and `pylint`. |
| 31 | + |
| 32 | +### 4. **Library Compatibility** |
| 33 | + |
| 34 | +Ensure compatibility with the following library versions: |
| 35 | + |
| 36 | +* `sqlalchemy` ≥ 2.x |
| 37 | +* `pydantic` ≥ 2.x |
| 38 | +* `fastapi` ≥ 0.100 |
| 39 | + |
| 40 | + |
| 41 | +### 5. **Code Practices** |
| 42 | + |
| 43 | +* Use `f-string` formatting for all string interpolation except for logging message strings. |
| 44 | +* Use **relative imports** within the same package/module. |
| 45 | +* Place **all imports at the top** of the file. |
| 46 | +* Document functions when the code is not self-explanatory or if asked explicitly. |
| 47 | + |
| 48 | + |
| 49 | +### 6. **JSON Serialization** |
| 50 | + |
| 51 | +* Prefer `json_dumps` / `json_loads` from `common_library.json_serialization` instead of the built-in `json.dumps` / `json.loads`. |
| 52 | +* When using Pydantic models, prefer methods like `model.model_dump_json()` for serialization. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## 🛠️Coding Instructions for Node.js in This Repository |
| 57 | + |
| 58 | +* Use ES6+ syntax and features. |
| 59 | +* Follow the `package.json` configuration for dependencies and scripts. |
| 60 | +* Use `eslint` for linting and `prettier` for code formatting. |
| 61 | +* Write modular and reusable code, adhering to the project's structure. |
0 commit comments