[mypy] Add type hints and docstrings to heap.py (#3013)
[mypy] Add type hints and docstrings to heap.py (#3013)

* Add type hints and docstrings to heap.py

- Add type hints
- Add docstrings
- Add explanatory comments 
- Improve code readability
- Change to use f-string

* Fix import sorting

* fixup! Format Python code with psf/black push

* Fix static type error

* Fix failing test

* Fix type hints

* Add return annotation

Co-authored-by: github-actions <47a35b99ddbe74edbea9dad62cf9a3b212194173@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <482973f2a44b929137ace410c8397045079496c1@gmail.com>
TheAlgorithms/Python