You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+66-7Lines changed: 66 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,13 +25,23 @@ After completing all steps, the project root should look like this:
25
25
```
26
26
RDP_HTTPX/
27
27
├── .github/
28
-
│ └── copilot-instruction.md
28
+
│ └── copilot-instructions.md
29
29
├── .venv/ # virtual environment (not committed to Git)
30
+
├── .vscode/
31
+
│ └── launch.json
32
+
├── images/
30
33
├── src/
31
34
│ ├── .env # local secrets (not committed to Git)
32
-
│ └── .env.example # template committed to Git
35
+
│ ├── .env.example # template committed to Git
36
+
│ ├── async_call_nb.ipynb
37
+
│ ├── example_async_gather.py
38
+
│ ├── example_client.py
39
+
│ ├── example_sync_httpx.py
40
+
│ └── sync_call_nb.ipynb
33
41
├── .gitignore
42
+
├── Article.md
34
43
├── LICENSE.md
44
+
├── README.md
35
45
└── requirements.txt
36
46
```
37
47
@@ -177,15 +187,15 @@ Next, create file name `launch.json` in `.vscode/` folder with the following con
177
187
178
188
## Part 2: Initialize the Git Repository
179
189
180
-
### Step 8 — Add `LICENSE.md`
190
+
### Step 9 — Add `LICENSE.md`
181
191
182
192
Create `LICENSE.md` in the project root containing the full [Apache 2.0 license text](https://www.apache.org/licenses/LICENSE-2.0):
183
193
184
194
Then change the `Copyright [yyyy] [name of copyright owner]` line to `Copyright 2026 LSEG`.
185
195
186
196
---
187
197
188
-
### Step 9 — Add `.gitignore`
198
+
### Step 10 — Add `.gitignore`
189
199
190
200
Create a `.gitignore` file in the project root suitable for Python projects. Use the template from [gitignore.io for Python](https://www.toptal.com/developers/gitignore/api/python).
191
201
@@ -201,7 +211,7 @@ The `.gitignore` **must** include the following entries (add them if not already
201
211
202
212
---
203
213
204
-
### Step 10 — Initialize Git and create the initial commit
214
+
### Step 11 — Initialize Git and create the initial commit
205
215
206
216
Run the following commands in order from the project root:
207
217
@@ -213,7 +223,7 @@ git commit -m "init main"
213
223
214
224
---
215
225
216
-
### Step 11 — Rename the default branch to `main`
226
+
### Step 12 — Rename the default branch to `main`
217
227
218
228
```bash
219
229
git branch -m master main
@@ -231,7 +241,7 @@ Expected output: `* main`
231
241
232
242
## Part 3: Validation
233
243
234
-
### Step 12 — Run a package smoke test
244
+
### Step 13 — Run a package smoke test
235
245
236
246
Run a one-line Python check to confirm `httpx` and `python-dotenv` are installed and import correctly.
237
247
@@ -250,3 +260,52 @@ If successful, output should include:
250
260
-`python-dotenv` followed by a version number
251
261
-`dotenv module path` pointing to the virtual environment site-packages directory
252
262
263
+
---
264
+
265
+
## Part 4: Code Style
266
+
267
+
All Python source files in this project must follow these conventions:
268
+
269
+
### General
270
+
271
+
- Follow [PEP 8](https://peps.python.org/pep-0008/) for formatting and naming.
272
+
- Use 4 spaces for indentation (no tabs).
273
+
- Maximum line length: 120 characters.
274
+
- Use `snake_case` for functions and variables, `UPPER_SNAKE_CASE` for module-level constants.
275
+
- Use double quotes (`"`) for strings.
276
+
277
+
### Imports
278
+
279
+
- Group imports in this order: standard library, third-party packages, local modules.
280
+
- Separate each group with a blank line.
281
+
- Import `httpx` and `dotenv` as top-level imports (not inside functions).
282
+
283
+
### Docstrings & Comments
284
+
285
+
- Every public function must have a one-line docstring enclosed in triple double-quotes (`"""`).
286
+
- Use inline comments sparingly to explain *why*, not *what*.
287
+
288
+
### Type Hints
289
+
290
+
- Use type hints for function return types (e.g., `-> dict[str, str]`).
291
+
- Parameter type hints are optional but encouraged for public functions.
292
+
293
+
### Environment Variables
294
+
295
+
- Load environment variables via `python-dotenv` (`load_dotenv()`).
296
+
- Access secrets only through `os.getenv()` — never hard-code credentials.
297
+
- Use a helper function (e.g., `_require_env`) to fail early on missing required variables.
298
+
299
+
### HTTP Requests
300
+
301
+
- Use `httpx` for all HTTP calls (both sync and async).
302
+
- Always call `response.raise_for_status()` after requests to surface API errors.
303
+
- Use `data=` for form-encoded payloads and `json=` for JSON payloads.
304
+
- For async code, use `httpx.AsyncClient` as a context manager and control concurrency with `asyncio.Semaphore`.
305
+
306
+
### Error Handling
307
+
308
+
- Raise exceptions early for missing configuration.
309
+
- Let `httpx` exceptions propagate unless specific recovery logic is needed.
310
+
-`dotenv module path` pointing to the virtual environment site-packages directory
0 commit comments