Improve the development workflow by drawing inspiration from The Complete Python Development Guide
- Dominant language
- Python
- Stars
- 564
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
[The Complete Python Development Guide](https://testdriven.io/guides/complete-python/) is an amazing series of articles on how to improve the Python development workflow, from dependency management to testing, documentation and building/shipping packages with CI/CD pipelines.
It promotes the use of:
- [pyenv](https://github.com/pyenv/pyenv) and [Poetry](https://python-poetry.org/) for dependency and workspace management
- [Flake8](https://flake8.pycqa.org/en/latest/) as a linter
- [isort](https://github.com/PyCQA/isort) to organize imports
- [Black](https://github.com/psf/black) to format code
- [Bandit](https://github.com/PyCQA/bandit) and [Safety](https://github.com/pyupio/safety) to find common security issues
In addition, [this article on Medium](https://betterprogramming.pub/build-a-pre-commit-workflow-to-check-and-fix-your-python-code-automatically-313deb5a5701) explains how to configure pre-hook commits in Git with [pre-commit](https://pre-commit.com/) to check and fix the new code before it reaches the CI stage. `Flake8`, `black`, `isort`, `pylint` and `mypy` all provide ready-to-use Git hooks with customizable arguments.
Could these tools/techniques replace built-in features of PyCharm like Optimize Imports and Reformat Code? Then switching to Visual Code should be a no-brainer.
As an added benefit, formatting the code with `black` and `isort` could simplify the `pylint` calls by removing some (all?) currently ignored warnings like:
- E203 (Whitespace before ':')
- E261 (At least two spaces before inline comment)
- E302 (Expected 2 blank lines, found 0)
- E402 (Module level import not at top of file)
As a result, invoking `flake8` could be as simple as: `flake8 "slo_generator"/ --max-line-length=88` (88 is the default for `black` and usually gives good results). I just confirmed that running `black slo_generator` followed by `flake8 "slo_generator"/ --max-line-length=88` returns with no errors. Finally, [this article](https://cereblanco.medium.com/setup-black-and-isort-in-vscode-514804590bf9#:~:text=Edit%20(25th%20April%202021)%3A%0AUpdate%3A%0AYou%20can%20configure%20Black%20and%20Isort%E2%80%99s%20settings%20on%20pyproject.toml.%0AInside%20your%20root%E2%80%99s%20project%20folder%2C%20create%20or%20update%20your%20pyproject.toml%20file%20to%20include) even mentions that the configuration of each tool can be stored in Poetry's `pyproject.toml` and applied on every save. Coupled with pre-commit hooks, that could greatly simplify and speed up the development workflow.
Another code formatter worth considering is Google's own [`yapf`](https://github.com/google/yapf), whose source code is itself formatted by `yapf`.
Contributor guide
Assessment
This issue has not been assessed yet.