Skip to content

Commit d0b13e3

Browse files
committed
add setup instructions for HTTPX Python project in copilot-instructions.md file
1 parent 4d118db commit d0b13e3

1 file changed

Lines changed: 66 additions & 7 deletions

File tree

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,23 @@ After completing all steps, the project root should look like this:
2525
```
2626
RDP_HTTPX/
2727
├── .github/
28-
│ └── copilot-instruction.md
28+
│ └── copilot-instructions.md
2929
├── .venv/ # virtual environment (not committed to Git)
30+
├── .vscode/
31+
│ └── launch.json
32+
├── images/
3033
├── src/
3134
│ ├── .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
3341
├── .gitignore
42+
├── Article.md
3443
├── LICENSE.md
44+
├── README.md
3545
└── requirements.txt
3646
```
3747

@@ -177,15 +187,15 @@ Next, create file name `launch.json` in `.vscode/` folder with the following con
177187

178188
## Part 2: Initialize the Git Repository
179189

180-
### Step 8 — Add `LICENSE.md`
190+
### Step 9 — Add `LICENSE.md`
181191

182192
Create `LICENSE.md` in the project root containing the full [Apache 2.0 license text](https://www.apache.org/licenses/LICENSE-2.0):
183193

184194
Then change the `Copyright [yyyy] [name of copyright owner]` line to `Copyright 2026 LSEG`.
185195

186196
---
187197

188-
### Step 9 — Add `.gitignore`
198+
### Step 10 — Add `.gitignore`
189199

190200
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).
191201

@@ -201,7 +211,7 @@ The `.gitignore` **must** include the following entries (add them if not already
201211

202212
---
203213

204-
### Step 10 — Initialize Git and create the initial commit
214+
### Step 11 — Initialize Git and create the initial commit
205215

206216
Run the following commands in order from the project root:
207217

@@ -213,7 +223,7 @@ git commit -m "init main"
213223

214224
---
215225

216-
### Step 11 — Rename the default branch to `main`
226+
### Step 12 — Rename the default branch to `main`
217227

218228
```bash
219229
git branch -m master main
@@ -231,7 +241,7 @@ Expected output: `* main`
231241

232242
## Part 3: Validation
233243

234-
### Step 12 — Run a package smoke test
244+
### Step 13 — Run a package smoke test
235245

236246
Run a one-line Python check to confirm `httpx` and `python-dotenv` are installed and import correctly.
237247

@@ -250,3 +260,52 @@ If successful, output should include:
250260
- `python-dotenv` followed by a version number
251261
- `dotenv module path` pointing to the virtual environment site-packages directory
252262

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
311+

0 commit comments

Comments
 (0)