|
| 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. **Use Python 3.11**: Ensure that all Python-related suggestions align with Python 3.11 features and syntax. |
| 8 | +2. **Node.js Compatibility**: For Node.js projects, ensure compatibility with the version specified in the project (e.g., Node.js 14 or later). |
| 9 | +3. **Follow Coding Conventions**: Adhere to the coding conventions outlined in the `docs/coding-conventions.md` file. |
| 10 | +4. **Test-Driven Development**: Write unit tests for all new functions and features. Use `pytest` for Python and appropriate testing frameworks for Node.js. |
| 11 | +5. **Environment Variables**: Use environment variables as specified in `docs/env-vars.md` for configuration. Avoid hardcoding sensitive information. |
| 12 | +6. **Documentation**: Prefer self-explanatory code; add documentation only if explicitly requested by the developer. |
| 13 | + |
| 14 | +## Python-Specific Instructions |
| 15 | + |
| 16 | +- Always use type hints and annotations to improve code clarity and compatibility with tools like `mypy`. |
| 17 | + - An exception to that rule is in `test_*` functions return type hint must not be added |
| 18 | +- Follow the dependency management practices outlined in `requirements/`. |
| 19 | +- Use `ruff` for code formatting and for linting. |
| 20 | +- Use `black` for code formatting and `pylint` for linting. |
| 21 | +- ensure we use `sqlalchemy` >2 compatible code. |
| 22 | +- ensure we use `pydantic` >2 compatible code. |
| 23 | +- ensure we use `fastapi` >0.100 compatible code |
| 24 | +- use f-string formatting |
| 25 | +- Only add comments in function if strictly necessary |
| 26 | + |
| 27 | + |
| 28 | +### Json serialization |
| 29 | + |
| 30 | +- Generally use `json_dumps`/`json_loads` from `common_library.json_serialization` to built-in `json.dumps` / `json.loads`. |
| 31 | +- Prefer Pydantic model methods (e.g., `model.model_dump_json()`) for serialization. |
| 32 | + |
| 33 | + |
| 34 | +## Node.js-Specific Instructions |
| 35 | + |
| 36 | +- Use ES6+ syntax and features. |
| 37 | +- Follow the `package.json` configuration for dependencies and scripts. |
| 38 | +- Use `eslint` for linting and `prettier` for code formatting. |
| 39 | +- Write modular and reusable code, adhering to the project's structure. |
| 40 | + |
| 41 | +## Copilot Usage Tips |
| 42 | + |
| 43 | +1. **Be Specific**: Provide clear and detailed prompts to Copilot for better suggestions. |
| 44 | +2. **Iterate**: Review and refine Copilot's suggestions to ensure they meet project standards. |
| 45 | +3. **Split Tasks**: Break down complex tasks into smaller, manageable parts for better suggestions. |
| 46 | +4. **Test Suggestions**: Always test Copilot-generated code to ensure it works as expected. |
| 47 | + |
| 48 | +## Additional Resources |
| 49 | + |
| 50 | +- [Python Coding Conventions](../docs/coding-conventions.md) |
| 51 | +- [Environment Variables Guide](../docs/env-vars.md) |
| 52 | +- [Steps to Upgrade Python](../docs/steps-to-upgrade-python.md) |
| 53 | +- [Node.js Installation Script](../scripts/install_nodejs_14.bash) |
0 commit comments