Skip to content

This project is intended to help developers to code better using Python best practices

License

Notifications You must be signed in to change notification settings

claudiosw/python-best-practices

Repository files navigation

About

This repository has examples to help developers understand and improve their Python coding practices.

Related to this, there is a series of Linkedin posts that will be a suitable complement:

  1. Python Recommended coding practices - part 1: PEP8 explains about PEP8, its name conventions, code layout and linters.
  2. Python Recommended coding practices - part 2: Clean Code: In this article, I wrote about Python Clean Code practices.
  3. Python Recommended coding practices - part 3: SOLID Principles: In this article, I wrote about the SOLID principles with Python examples.
  4. Testing in Python using Pytest and Mock: In this article, I wrote about Pytest and Mock. I discussed basic use, fixtures, markers, parametrization and duration.
  5. Good Practices for Documenting Python Code: In this article I wrote about documentation in Python, including Type Hinting and Docstrings. And how to use Sphinx to generate HTML (or other format) documentation from the Docstrings.

Each folder of this project is related to one specific topic:

  • .vscode: This folder contain example of VSCode configuration.
  • clean_code: This folder contains examples for "Clean Code" principles.
  • documenting: This folder contains examples for code documentation.
  • pep8: This folder contains examples for PEP8 style guidelines.
  • solid: This folder contains examples for SOLID principles.
  • testing: This folder contains examples for testing, including Pytest examples and using mocking.
  • .gitignore: This file contain patterns for ignoring files and folders on your local computer to GitHub.
  • .pre-commit-config.yaml: This file containes configuration for all the pre-commit tasks.

Instalation

On prompt, acess the directory that want to download the project

git clone https://github.com/claudiosw/python-best-practices.git

Create the virtual environment:

python -m venv venv

Run the virtual environment:

Windows

venv\Scripts\activate

Linux/MacOS

source venv/bin/activate

Install the required Python packages:

pip install -r requirements.txt
pre-commit install

If you need to regenerate the Docs, execute: (You may need to run “./make.bat html” on Windows)

sphinx-apidoc -f -o docs/source .
make clean html
make html

Documentation

You can see the documentation of this project generated for Sphinx in here.

About

This project is intended to help developers to code better using Python best practices

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages