Python ist leicht zu lernen, schwer zu meistern. Diese Best Practices unterscheiden Sie von Anfängern.
Projektstruktur¶
myproject/ ├── src/myproject/ │ ├── __init__.py │ ├── main.py │ └── models.py ├── tests/ │ └── test_main.py ├── pyproject.toml ├── README.md └── .gitignore
pyproject.toml¶
[project] name = “myproject” version = “0.1.0” requires-python = “>=3.12” [tool.ruff] line-length = 100 select = [“E”, “F”, “I”, “UP”] [tool.mypy] strict = true
Kernprinzipien¶
- Type Hints überall
- Ruff für Linting und Formatierung
- mypy –strict für Type Checking
- pytest für Tests
- Virtual Environment immer
Wichtigste Erkenntnis¶
Type Hints + Ruff + mypy + pytest = professionelles Python. pyproject.toml als Single Source of Truth.