Python development environment options for May 2020

Introduction

The appeal of Python is that you can write and run it as soon as you install it, If you actually want to write it in business etc.

--Python version control tool --Package manager --Editor (IDE) --Linter --Formatter --Type checker

At a minimum, you need to prepare. However, in this neighborhood, new things are released every day with angry momentum, and it is difficult to unconditionally present "this is the best practice". So, this time, I would like to introduce "there is something like this" for each of the above tools.

TLDR --Version / package management is over when pyenv + Pipenv was the standard --If you use VS Code or Vim, you should introduce Pyright for type analysis. -Template prepared

1. Version / Package Manager

A tool for using different Python versions and packages for each project. For a long time, pyenv + Pipenv has been said to be the standard of the new era, but now it is back to the era of group male division.

Are the top two documents rich in Japanese? Personally, I like pyenv + Poetry. For details, please read the article below as it is wonderful.

** Python Package Management Best Practices for 2020 **

In Python 3.8, there is a proposal called ** PEP 582 ** that says "Can't stop the virtual environment anymore?" It is expected that management around here will be easier once this is officially incorporated. Light on Windows (NT kernel).

2. Editor (IDE)

Notepad with lots of useful features for writing code. I can't write all the options, so I'll omit them. Unless you are particular about it, we recommend VS Code.

--Code completion works --Can be debugged --Linter / formatter / type checker works

You can use any editor as long as you meet the above three requirements. Conversely, do not use an editor that does not meet these requirements (such as XXX or XX) for business purposes.

3. Linter

This is a tool to check if the code you wrote violates the coding rules. I think this is an option to customize flake8 according to the formatter you use. If you know any other good things, please let me know.

Note that flake8 has to update pycodestyle from GitHub due to a dependency package issue until about a month ago. I was getting an error in Walrus operator, but when I checked it now, it was resolved.

4. Formatter

It is a tool that automatically formats the written code according to the coding rules. It used to be like using autopep8, but now it's like using it.

And there are three options. The following articles are detailed about each feature.

** Determined by this! 3 strongest automatic code formatting tools! **

I'm using yapf because the black format wasn't accepted for some religious reason.

5. Type checker

A tool for writing Python like a statically typed language. The choices are

--If you use VS Code or Vim as an editor, Pyright --If you don't use it, mypy --If you can't stand the slowness of mypy Pyre

Is it three? I don't know where to use pytype ...

Pyright is faster than mypy (5x MS says) and can perform type checking on large projects without stress. To be honest, this is good enough to be a reason to use VS Code. mypy works with Vim, Emacs, Sublime Text, Atom, PyCharm and VS Code. Like Pyright, Pyre is a type checker that sells faster than mypy, but It's used differently (notifies the server of file changes), so be sure to read the Official Documentation.

in conclusion

That's why it was an introduction about each tool. I am currently

  1. pyenv + Poetry
  2. VS Code
  3. flake8
  4. yapf
  5. Pyright

With the configuration of, I am developing with Poetry Settings set to virtualenvs.in-project = true. ** I prepared a template repository **, so I hope you can refer to how to write the configuration file that should be placed in the project. ..

In addition, the Git Hooks management tool ** pre-commit **, which is also used in black above, is also ** required for team development **. Please also read the article below. Write Git Hooks in Python (etc.) and manage it in Python

Recommended Posts

Python development environment options for May 2020
[For organizing] Python development environment
Emacs settings for Python development environment
Python development environment for macOS using venv 2016
Building a Python development environment for AI development
Python development environment construction
About Python development environment
python2.7 development environment construction
Development environment in Python
Python environment for projects
Development environment suitable for ArcPy
Python environment construction For Mac
Python3 environment construction (for beginners)
Organize your Python development environment
[ev3dev × Python] Build ev3dev development environment
[MEMO] [Development environment construction] Python
python memo (for myself): About the development environment virtualenv
Prepare Python development environment on Ubuntu
[For beginners] Django -Development environment construction-
Building a development environment for Android apps-creating Android apps in Python
Prepare your first Python development environment
[Python3] Development environment construction << Windows edition >>
Python development environment construction on macOS
Vim + Python development environment setting memo
Smooth Python development environment for teams [Poetry + pyenv + black + isort]
Install Python development environment on Windows 10
Python3 TensorFlow for Mac environment construction
Emacs Python development environment construction memo
Checking the NAOqi Python development environment
Prepare Python development environment with Atom
Build a local development environment for Lambda + Python using Serverless Framework
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Build an environment for Blender built-in Python
[Development environment] Python with Xcode [With screen transition]
Python project environment construction procedure (for windows)
Blender 2.82 or later + python development environment notes
Python environment tool comparison chart for Rubyist
Let's create a virtual environment for Python
Creating amateur python environment settings (for MAC)
6 Python libraries for faster development and debugging
Python3 + venv + VSCode + macOS development environment construction
[Mac] Building a virtual environment for Python
Prepare the development environment for keyhac for Mac
Construction of development environment for Choreonoid class
Build Python development environment (pythonz, virtualenv, direnv)
The strongest Python development environment PyCharm's recommendation
Creating a development environment for machine learning
Windows + gVim + Poetry python development environment construction
The strongest Python integrated development environment PyCharm
2016-10-30 else for Python3> for:
python [for myself]
Prepare Python development environment for each project in Windows environment (VSCode + virtualEnvWrapper + Pylint)
Create a Python development environment locally at the fastest speed (for beginners)
Python environment construction
python windows environment
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Selenium + WebDriver (Chrome) + Python | Building environment for scraping