Python Rules
python -m venv .venv
to create isolated environments unless the project uses Poetry or Conda. - Avoid installing packages globally. - Use requirements.txt
or pyproject.toml
for dependencies.pytest
for test automation unless the project is based on unittest
. - Use fixtures or mocks for external systems (e.g., DBs, APIs). - Follow Arrange-Act-Assert in tests.black
, ruff
, or flake8
. - Use type hints for all public functions. - Prefer comprehensions over loops for simple list/tuple generation. - Avoid bare except:
clauses — catch specific exceptions.