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
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).
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.
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.
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.
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.
That's why it was an introduction about each tool. I am currently
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