|
| 1 | +# FEATURE MANAGEMENT FOR PYTHON - COPILOT INSTRUCTIONS |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +## CORE PRINCIPLES |
| 6 | + |
| 7 | +### RULE 1: DO NOT REPEAT INSTRUCTIONS |
| 8 | +**NEVER repeat instructions when guiding users. Users should follow instructions independently.** |
| 9 | + |
| 10 | +### RULE 2: REFERENCE OFFICIAL DOCUMENTATION |
| 11 | +**ALWAYS** reference the [Azure SDK Python Design Guidelines](https://azure.github.io/azure-sdk/python_design.html) |
| 12 | +- Link to specific pages when answering guidelines questions |
| 13 | +- Use this as the authoritative source for SDK development guidance |
| 14 | + |
| 15 | +### RULE 3: VERIFY ENVIRONMENT FIRST |
| 16 | +**REQUIRED CONDITIONS:** |
| 17 | +- Always activate the Python virtual environment before running Python commands: |
| 18 | + - On Windows: `.venv\Scripts\activate` |
| 19 | + - On Linux/macOS: `source .venv/bin/activate` |
| 20 | +- Use `python -m pip` instead of bare `pip` when installing packages. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## DEV SETUP |
| 25 | + |
| 26 | +Install all dependencies with: |
| 27 | + |
| 28 | +```bash |
| 29 | +python -m pip install -e ".[dev,test]" |
| 30 | +``` |
| 31 | + |
| 32 | +This project requires **Python 3.10 or newer**. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## PROJECT STRUCTURE |
| 37 | + |
| 38 | +- `featuremanagement/` — Synchronous feature management code |
| 39 | +- `featuremanagement/aio/` — Async equivalents of feature management classes |
| 40 | +- `featuremanagement/_models/` — Data models (feature flags, variants, telemetry) |
| 41 | +- `featuremanagement/_time_window_filter/` — Time window filter with recurrence support |
| 42 | +- `featuremanagement/azuremonitor/` — Optional Azure Monitor telemetry integration |
| 43 | +- `tests/` — Unit tests (sync and async) |
| 44 | +- `samples/` — Sample applications |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## CODE CONVENTIONS |
| 49 | + |
| 50 | +- All source files must include the Microsoft copyright header. |
| 51 | +- All modules must have a module-level docstring. |
| 52 | +- Maximum line length is 120 characters. |
| 53 | +- Use type annotations on all functions and methods. |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## PYLINT OPERATIONS |
| 58 | + |
| 59 | +### RUNNING PYLINT |
| 60 | + |
| 61 | +**COMMAND:** |
| 62 | +```bash |
| 63 | +pylint featuremanagement |
| 64 | +``` |
| 65 | + |
| 66 | +### FIXING PYLINT WARNINGS |
| 67 | + |
| 68 | +**ALLOWED ACTIONS:** |
| 69 | +- ✅ Fix warnings with 100% confidence |
| 70 | +- ✅ Use existing files for all solutions |
| 71 | +- ✅ Reference official guidelines |
| 72 | + |
| 73 | +**FORBIDDEN ACTIONS:** |
| 74 | +- ❌ Fix warnings without complete confidence |
| 75 | +- ❌ Create new files for solutions |
| 76 | +- ❌ Import non-existent modules |
| 77 | +- ❌ Add new dependencies/imports |
| 78 | +- ❌ Make unnecessary large changes |
| 79 | +- ❌ Change code style without reason |
| 80 | +- ❌ Delete code without clear justification |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## MYPY OPERATIONS |
| 85 | + |
| 86 | +### RUNNING MYPY |
| 87 | + |
| 88 | +**COMMAND:** |
| 89 | +```bash |
| 90 | +mypy featuremanagement |
| 91 | +``` |
| 92 | + |
| 93 | +The project uses `strict = True` in `mypy.ini`. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## CODE FORMATTING |
| 98 | + |
| 99 | +### RUNNING BLACK |
| 100 | + |
| 101 | +**COMMAND:** |
| 102 | +```bash |
| 103 | +black featuremanagement |
| 104 | +``` |
| 105 | + |
| 106 | +Line length is configured to 120 in `pyproject.toml`. |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## TESTING |
| 111 | + |
| 112 | +### RUNNING TESTS |
| 113 | + |
| 114 | +**COMMAND:** |
| 115 | +```bash |
| 116 | +pytest tests |
| 117 | +``` |
| 118 | + |
| 119 | +- Sync tests are in `tests/test_*.py` |
| 120 | +- Async tests use `pytest-asyncio` and are in files ending with `_async.py` |
| 121 | +- Run tests with: `pytest tests` |
0 commit comments