GitHub Copilot instructions for Python project coding standards, naming conventions, and error handling best practices from python_template kitchensink project.
Instructions for GitHub Copilot to enforce coding standards and best practices in Python projects.
Configures GitHub Copilot to follow consistent coding standards including naming conventions, error handling patterns, and code organization practices. Based on the python_template kitchensink project by floppyinfant.
When using this skill in a project, apply the following standards:
- Examples: `UserProfile`, `DatabaseConnection`, `ResponseType`
- Examples: `userData`, `getUserById()`, `calculateTotal()`
- Examples: `_internalState`, `_privateMethod()`
- Examples: `MAX_RETRIES`, `DEFAULT_TIMEOUT`, `API_VERSION`
Implement robust error handling throughout the codebase:
```python
try:
result = await async_operation()
except Exception as e:
logger.error(f"Operation failed: {e}")
```
- Include operation name, input parameters, timestamp
- Use appropriate log levels (ERROR, WARNING, INFO)
```python
class UserManager:
MAX_LOGIN_ATTEMPTS = 3 # Constant in ALL_CAPS
def __init__(self):
self._userCache = {} # Private member with underscore
def getUserData(self, userId): # Method in camelCase
try:
return self._fetchFromCache(userId)
except KeyError as e:
logger.error(f"User {userId} not found in cache: {e}")
raise
```
```python
async def processRequest(requestData):
try:
result = await apiClient.send(requestData)
return result
except ConnectionError as e:
logger.error(f"Connection failed for request {requestData.id}: {e}")
raise
except Exception as e:
logger.error(f"Unexpected error processing request {requestData.id}: {e}")
raise
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/python-template-copilot-standards/raw