-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fd2a21
commit 15a6c11
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Contributing | ||
|
||
## Setting up an environment | ||
|
||
Clone the `asyncio-mqtt`. | ||
|
||
Inside the repository, create a virtual environment. | ||
|
||
```bash | ||
python3 -m venv env | ||
``` | ||
|
||
Activate the virtual environment. | ||
|
||
```bash | ||
source ./env/bin/activate | ||
``` | ||
|
||
Upgrade `pip`. | ||
|
||
```bash | ||
pip install --upgrade pip | ||
``` | ||
|
||
Install the development dependencies. | ||
|
||
```bash | ||
pip install -e .[tests,lint,format] | ||
``` | ||
|
||
Install [pre-commit](https://pre-commit.com/) so that your code is formatted and checked when you are doing a commit. | ||
|
||
```bash | ||
pip install pre-commit | ||
pre-commit install | ||
``` | ||
|
||
### Visual Studio Code | ||
|
||
If you are using VSCode, here are the settings to activate on save, | ||
|
||
- `black` and `isort` to format. | ||
- `flake8` and `mypy` to lint. | ||
|
||
```json | ||
{ | ||
"[python]": { | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
}, | ||
"python.formatting.provider": "black", | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.mypyEnabled": true | ||
} | ||
``` | ||
|
||
## Testing | ||
|
||
To test the code use [pytest](https://docs.pytest.org/en/7.1.x/). | ||
|
||
```bash | ||
pytest | ||
``` | ||
|
||
To do the full coverage of `asyncio-mqtt`, run the following command. | ||
|
||
```bash | ||
pytest --cov=src --cov=tests --cov-report=html | ||
``` | ||
|
||
To view the coverage open `htmlcov/index.html`. | ||
|
||
## Committing | ||
|
||
After doing `git commit`, `pre-commit` will check the committed code. | ||
The check can be passed, skipped or failed. | ||
If the check failed, it is possible it auto-fixed the code, so you will only need to stage and commit again for it to pass. | ||
If it did not auto-fixed the code, you will need to do it manually. | ||
`pre-commit` will only check the code that is staged, the unstaged code will be stashed during the checks. |