- Use 4 spaces per indentation level.
- Use meaningful variable and function names.
- Write docstrings for all public modules, classes, functions, and methods.
- Avoid global variables.
- Prefer list comprehensions and generator expressions where appropriate.
- Use type hints for function signatures.
- Group imports in the following order: standard library, third-party, local application/library.
- Use exceptions for error handling, not return codes.
- Catch specific exceptions, not broad ones.
- Write unit tests for all modules.
- Use pytest or unittest frameworks.
import os
from typing import List
def process_items(items: List[str]) -> None:
"""Process a list of items."""
for item in items:
print(item)