Contributing to Kapowarr consists of 5 steps, listed hereunder.
- Make a contributing request, where you describe what you plan on doing. This request needs to get approved before you can start. The contributing request has multiple uses:
- Avoid multiple people working on the same thing.
- Avoid you wasting your time on changes that we do not wish for.
- If needed, have discussions about how something will be implemented.
- A place for contact, be it questions, status updates or something else.
- When the request is accepted, start your local development (more info on this below).
- 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.
- The PR will be reviewed. Changes might need to be made in order for it to be merged.
- When everything is okay, the PR will be accepted and you'll be done!
Once your contribution request has been accepted, you can start your local development.
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.
- The vs code extension
ms-python.vscode-pylance
in combination with the settings file with enable type checking. - The vs code extension
ms-python.mypy-type-checker
in combination with the settings file will enable mypy checking. - The vs code extension
ms-python.autopep8
in combination with the settings file will format code on save. - The vs code extension
ms-python.isort
in combination with the settings file will sort the import statements on save. - 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.
- Mypy:
mypy --explicit-package-bases .
- autopep8:
autopep8 --recursive --in-place .
- isort:
isort .
- unittest
python3 -m unittest discover -s ./tests -p '*.py'
There are a few conditions that should always be met:
- Kapowarr should support Python version 3.8 and higher.
- Kapowarr should be compatible with Linux, MacOS, Windows and the Docker container.
- The tests should all pass.
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.
- Indentation is done with 4 spaces. Not using tabs.
- 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
. - 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.
- The imports need to be sorted.
- The code should, though not strictly enforced, reasonably comply with the rule of 80 characters per line.
- Kapowarr does not have many tests. They're not really required if you checked your changes for bugs already. But you are free to add tests for your changes anyway.
- The function
backend.base.file_extraction.extract_filename_data
and the regexes defined at the top that it uses have become a bit of a box of black magic. If the function does not work as expected, it might be best to just inform @Casvt in the contribution request issue and he'll try to fix it.