mirror of
https://github.com/Casvt/MIND.git
synced 2026-02-19 11:54:46 -05:00
65 lines
3.3 KiB
Markdown
65 lines
3.3 KiB
Markdown
# Contributing to MIND
|
|
## General steps
|
|
Contributing to MIND consists of 5 steps, listed hereunder.
|
|
|
|
1. Make a [contributing request](https://github.com/Casvt/MIND/issues/new?template=3_contribute_request.yml), where you describe what you plan on doing. _This request needs to get approved before you can start._ The contributing request has multiple uses:
|
|
1. Avoid multiple people working on the same thing.
|
|
2. Avoid you wasting your time on changes that we do not wish for.
|
|
3. If needed, have discussions about how something will be implemented.
|
|
4. A place for contact, be it questions, status updates or something else.
|
|
2. When the request is accepted, start your local development (more info on this below).
|
|
3. When done, create a pull request to the Development branch, where you quickly mention what has changed and give a link to the original contributing request issue.
|
|
4. The PR will be reviewed. Changes might need to be made in order for it to be merged.
|
|
5. When everything is okay, the PR will be accepted and you'll be done!
|
|
|
|
## Local development
|
|
|
|
Once your contribution request has been accepted, you can start your local development.
|
|
|
|
### IDE
|
|
|
|
It's up to you how you make the changes, but we use Visual Studio Code as the IDE. A workspace settings file is included that takes care of some styling, testing and formatting of the backend code.
|
|
|
|
1. The vs code extension `ms-python.vscode-pylance` in combination with the settings file with enable type checking.
|
|
2. The vs code extension `ms-python.mypy-type-checker` in combination with the settings file will enable mypy checking.
|
|
3. The vs code extension `ms-python.autopep8` in combination with the settings file will format code on save.
|
|
4. The vs code extension `ms-python.isort` in combination with the settings file will sort the import statements on save.
|
|
5. The settings file sets up the testing suite in VS Code such that you can just click the test button to run all tests.
|
|
|
|
If you do not use VS Code with the mentioned extensions, then below are some commands that you can manually run in the base directory to achieve similar results.
|
|
|
|
1. **Mypy**:
|
|
```bash
|
|
mypy --explicit-package-bases .
|
|
```
|
|
2. **autopep8**:
|
|
```bash
|
|
autopep8 --recursive --in-place .
|
|
```
|
|
3. **isort**:
|
|
```bash
|
|
isort .
|
|
```
|
|
4. **unittest**
|
|
```bash
|
|
python3 -m unittest discover -s ./tests -p '*.py'
|
|
```
|
|
|
|
### Strict rules
|
|
|
|
There are a few conditions that should always be met:
|
|
|
|
1. MIND should support Python version 3.8 and higher.
|
|
2. MIND should be compatible with Linux, MacOS, Windows and the Docker container.
|
|
3. The tests should all pass.
|
|
|
|
### Styling guide
|
|
|
|
Following the styling guide for the backend code is not a strict rule, but effort should be put in to conform to it as much as possible. Running autopep8 and isort handles most of this.
|
|
|
|
1. Indentation is done with 4 spaces. Not using tabs.
|
|
2. Use type hints as much as possible. If you encounter an import loop because something needs to be imported for type hinting, utilise [`typing.TYPE_CHECKING`](https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING).
|
|
3. A function in the backend needs a doc string describing the function, what the inputs are, what errors could be raised from within the function and what the output is.
|
|
4. The imports need to be sorted.
|
|
5. The code should, though not strictly enforced, reasonably comply with the rule of 80 characters per line.
|