-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.cursorrules
114 lines (114 loc) · 3.35 KB
/
.cursorrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
"projectRules": {
"apiGuidelines": {
"rateLimiting": {
"description": "Always implement rate limiting between API calls",
"example": "time.sleep(1) # Basic delay between calls",
"retryDelay": "time.sleep(2) # Longer delay for retries"
},
"errorHandling": {
"pattern": "Try-except with specific error types",
"returnValues": "Return None instead of raising exceptions for recoverable errors",
"retryLogic": "Implement retry for 500 errors with delays"
},
"logging": {
"levels": {
"debug": "Detailed technical information",
"info": "General operation success",
"warning": "Non-critical issues",
"error": "Critical issues"
},
"format": "Include context in logs: operation, IDs, results"
},
"payloadHandling": {
"minimal": "Only send required fields in updates",
"validation": "Validate input data before API calls"
}
},
"methodStructure": {
"documentation": {
"required": [
"Brief description",
"Args with types",
"Returns with types",
"Optional: Raises"
],
"format": "Use Google-style docstrings"
},
"typing": {
"required": true,
"imports": "from typing import Optional, Dict, List, Union"
}
},
"bestPractices": {
"delays": {
"beforeApiCalls": 1,
"betweenOperations": 1,
"forRetries": 2
},
"debugging": {
"required": [
"Request URL",
"Request Method",
"Request Payload",
"Response Status",
"Response Headers",
"Response Body"
]
},
"responseHandling": {
"nullCheck": "Always check for None before accessing response",
"pattern": "if response and response.get('field')"
}
},
"codeStructure": {
"imports": {
"order": [
"Standard library imports",
"Third-party imports",
"Local imports"
],
"grouping": "Group related imports together"
},
"classStructure": {
"order": [
"Class constants",
"Initialize method",
"Authentication methods",
"Helper methods",
"API methods"
]
}
}
},
"examplePatterns": {
"apiMethod": {
"template": [
"def method_name(self, param: str) -> Optional[Dict]:",
" \"\"\"Brief description.\"\"\"",
" try:",
" time.sleep(1)",
" response = requests.post(endpoint, headers=self.get_headers(), json=payload)",
" if response.status_code == 500:",
" time.sleep(2)",
" response = requests.post(endpoint, headers=self.get_headers(), json=payload)",
" return response.json() if response.ok else None",
" except Exception as e:",
" logger.error(f\"Error: {e}\")",
" return None"
]
},
"errorHandling": {
"template": [
"try:",
" # API call",
" if not response.ok:",
" logger.error(\"Request failed\")",
" return None",
"except Exception as e:",
" logger.error(f\"Error in API call: {e}\")",
" return None"
]
}
}
}