# Contributing

## Managing dependencies

### Poetry

To guarantee repeatable installations, all project dependencies are managed
using [Poetry](https://poetry.eustace.io/). The project’s direct dependencies are listed
in `pyproject.toml`. Running `poetry lock` generates `poetry.lock` which has all versions pinned.

You can install Poetry by using `pip install --pre poetry` or by following the official
installation guide [here](https://github.com/sdispater/poetry#installation).

If you're using a [PyCharm](https://www.jetbrains.com/pycharm/), also install
a [Poetry Plugin](https://plugins.jetbrains.com/plugin/14307-poetry).

### Other tools

For compatibility, YaTracker also provides `requirements.txt` and `requirements_dev.txt`.

## Coding style

YaTracker uses various tools to maintain a common coding style and help with development. To
install all the development tools, run the following commands:

```shell
python -m pip install -r requirements_dev.txt
```

or use `poetry`:

```shell
poetry install
```

### Pre-commit

YaTracker uses the [pre-commit](https://pre-commit.com/#install) tool to check and automatically
fix any formatting issue before creating a git commit.

Run the following command to install pre-commit into your git hooks and have it run on every
commit:

```shell
pre-commit install
```

For more information on how it works, see the `.pre-commit-config.yaml` configuration file.

### Commit naming

YaTracker using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) -
specification for adding human and machine-readable meaning to commit messages.

The commit message should be structured as follows:

**Commit message structure:**

```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```

**Examples:**

```
feat: implemented graceful close
BREAKING CHANGE: close method become async
```

```
fix: wrong object type
```

```
docs: add profile description
```

### Formatting

YaTracker has a strict formatting policy enforced by
the [black formatting tool](https://github.com/python/black).

### Typing

YaTracker has a strict typing policy enforced by the [mypy](https://github.com/python/mypy). All
functions with static typing must be described with the `typing` module. For example:

```python
from typing import List


def collect_integers(a: int, b: int) -> List[int]:
    return [a, b]
```

### Linters

- [black](https://github.com/python/black/) to make sure your code is correctly formatted.

- [isort](https://github.com/timothycrosley/isort) to maintain consistent imports.

- [pylint](https://www.pylint.org/) to catch errors in your code.

- [flake8](https://flake8.pycqa.org/en/latest/) to make sure your code adheres to PEP 8.

- [pydocstyle](http://pydocstyle.pycqa.org/en/latest/) to check that your docstrings are properly
  formatted.

- [mypy](https://github.com/python/mypy) to check that your types correctly assigned and used.

## EditorConfig

[EditorConfig](http://editorconfig.org/) is a standard configuration file that aims to ensure
consistent style across multiple programming environments.

YaTracker’s repository
contains [an `.editorconfig` file](https://github.com/Olegt0rr/YaTracker/blob/master/.editorconfig)
describing our formatting requirements.

Most editors and IDEs support this file either directly or via plugins. See
the [list of supported editors and IDEs](http://editorconfig.org/#download) for detailed
instructions.

If you make sure that your programming environment respects the contents of this file, you will
automatically get correct indentation, encoding, and line endings.

## Changelog
Our changelog is not autogenerated.
If you've changed something matters, don't forget to add it to the `[Unreleased]` section of the [Changelog](CHANGELOG.md)
