Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to make your code shine with isort, Black, Flake8, and Pylint. Guidelines and best practice suggestions on how to write Python code.

NotificationsYou must be signed in to change notification settings

mafda/python_best_practices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How can you make your code shine with isort, Black, Flake8 and Pylint?

In this repository, I would like to show some guidelines and best practice tipson how to write Python code.

We can use a simple deck of programs to get ourcodestylingdone. We can useisort for sorting the library imports (yes, imports have asuggested order), we can check the existence of undesired artifacts usingFlake8 andPylint, and we can keep the code within the same style usingBlack.

Those tools can be configured to bePEP8compliant.PEP8 — Python Enhancement Proposal, is a style guide thatprovides guidelines and best practices suggestions on how to write Python code.

Python tools

Project Setup

Clone this repository

(base)$: git clone git@github.com:mafda/python_best_practices.git(base)$:cd python_best_practices

Configure environment

  • Create the conda environment
(base)$: conda env create -f environment.yml
  • Activate the environment
(base)$: conda activate linear-regression
  • And run
(linear-regression)$: sh pep8.sh

Use these tools in your project and clean your code!

(base)$: conda env create -f environment-dev.yml(base)$: conda activate best-practices(best-practices)$:cd your-project

isort

You could useisort . orisort . --check-only

isort

Black

You could useblack --line-length 79 . orblack --line-length 79 --check .

black

Flake8

You could useflake8 .

flake8

Fix errors:

flake8

PyLint

You could usefind . -type f -name "*.py" | xargs pylint


made with 💙 bymafda

About

How to make your code shine with isort, Black, Flake8, and Pylint. Guidelines and best practice suggestions on how to write Python code.

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp