Skip to content

Latest commit

 

History

History
262 lines (180 loc) · 4.34 KB

CONTRIBUTING.md

File metadata and controls

262 lines (180 loc) · 4.34 KB

How to contribute

First, clone the repo (you may want to create a fork on GitHub).

git clone https://github.com/kHarshit/media-filesize-estimator.git

# if created fork, run
# git clone https://github.com/{YourGitHubUsername}/media-filesize-estimator.git

Dependencies

We use poetry to manage the dependencies. If you dont have poetry, you should install with make poetry-download.

It's recommended to use virtualenv or conda. If you're using conda, you can create a new env using

# create new env
conda create -n py3.8env python=3.8
# activate env
conda activate py3.8env

To install dependencies and prepare pre-commit hooks you would need to run install command:

make install
make pre-commit-install

To activate your virtualenv run poetry shell.

Codestyle

After installation you may execute code formatting.

make codestyle

Checks

Many checks are configured for this project. make test runs tests. Command make check-codestyle will check black, isort and darglint. The make check-safety command will look at the security of your code.

Comand make lint applies all checks.

Before submitting

Before submitting your code please do the following steps:

  1. Create a branch for your change using git checkout -b <branch_name>.
  2. Add any changes you want using git add <files_changed> & git commit -m "<git message>".
  3. Add tests for the new changes.
  4. Edit documentation if you have changed something significant.
  5. Run make codestyle to format your changes.
  6. Run make lint to ensure that tests, types, security and docstrings are okay.
  7. Push the changes to GitHub using git push -u origin <branch_name>.

Other help

You can contribute by spreading a word about this library. It would also be a huge contribution to write a short article on how you are using this project. You can also share your best practices with us.

Makefile usage

Makefile contains a lot of functions for faster development.

1. Download and remove Poetry

To download and install Poetry run:

make poetry-download

To uninstall

make poetry-remove

2. Install all dependencies and pre-commit hooks

Install requirements:

make install

Pre-commit hooks coulb be installed after git init via

make pre-commit-install

3. Codestyle

Automatic formatting uses pyupgrade, isort and black.

make codestyle

# or use synonym
make formatting

Codestyle checks only, without rewriting files:

make check-codestyle

Note: check-codestyle uses isort, black and darglint library

Update all dev libraries to the latest version using one comand

make update-dev-deps
4. Code security

make check-safety

This command launches Poetry integrity checks as well as identifies security issues with Safety and Bandit.

make check-safety

5. Type checks

Run mypy static type checker

make mypy

6. Tests with coverage badges

Run pytest

make test

7. All linters

Of course there is a command to rule run all linters in one:

make lint

the same as:

make test && make check-codestyle && make mypy && make check-safety

8. Docker

make docker-build

which is equivalent to:

make docker-build VERSION=latest

Remove docker image with

make docker-remove

More information about docker.

9. Cleanup

Delete pycache files

make pycache-remove

Remove package build

make build-remove

Delete .DS_STORE files

make dsstore-remove

Remove .mypycache

make mypycache-remove

Or to remove all above run:

make cleanup