As a Python Developer, I used many tools over the years. Here are my recommendations. In contrast to the rest of the things You can find here, this is just a suggestion.
I recommend using IDE. I personally use PyCharm, but if You prefer something lighter maybe check out Fleet. Whatever You use make sure it has tools for refactoring, code formatting, jumping to definitions, and better code completion like Codeinium or TabNine. I also use Sourcery (Refactoring) and sometimes SonarLint (Clean Code) or Snyk (Security).
I strongly recommend using black code formatting, and ruff for import sorting and linting. These two tools save a ton of time in code reviews and merging commits.
Using mypy for static typing checking lets you find common bugs and inconsistencies.
For testing, I recommend using pytest and pytest-cov.
For data classes, I recommend using attrs.
Templates
My package structure is usually divided into two main packages in the root folder: app and tests. Application code often contains three folders for clean architecture layers. Lately, I name them like this:
l0_domainl1_applicationl2_external
The test folder structure is heavily dependent on the project. I use max 120 characters per line because of mypy and the fact that we have bigger screens these days.
I often run the following commands:
black -l 120 app tests
ruff --line-length 120 --fix app tests
mypy app tests --disallow-untyped-defs
and for testing and debugging:
pytest
with coverage:
pytest --cov-report=term:skip-covered --cov-report=html:html_cov --cov-branch --cov=app
Template files:
requirements.txt
pip
setuptools
wheel
attrs
black
pytest
pytest-cov
ruff
.gitignore
.idea/
.mypy_cache/
.pytest_cache/
.ruff_cache/
__pycache__/
html_cov/
.coverage
.dcignore
*.pyc
I do the same for coverage (ex. abstract class):
# pragma: no cover
type check (usually something related to testing):
# type: ignore[rule, other-rule]
and linting with ruff (special cases or testing again):
# noqa: rule