Skip to content

Commit 893b5cf

Browse files
authored
Updates to Python Feature Management (#64)
* dependency update + strict * removing setup py usage * Create copilot-instructions.md * formatting * test and sample headers * pr comments * Update copilot-instructions.md * pr comments
1 parent f6afb9d commit 893b5cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+237
-121
lines changed

.github/copilot-instructions.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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`

.github/workflows/validate.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ jobs:
1717
- name: Install dependencies
1818
run: |
1919
python -m pip install --upgrade pip
20-
pip install -r dev_requirements.txt
21-
pip install .
20+
python -m pip install ".[dev]"
2221
- name: Analysing the code with pylint
2322
run: |
2423
pylint featuremanagement
@@ -30,9 +29,9 @@ jobs:
3029
uses: streetsidesoftware/cspell-action@v6.8.0
3130
- name: Test with pytest
3231
run: |
33-
pip install -r tests/requirements.txt
32+
python -m pip install ".[test]"
3433
pytest tests --doctest-modules --cov-report=xml --cov-report=html
3534
- name: Analysing the samples with pylint
3635
run: |
37-
pip install -r samples/requirements.txt
36+
python -m pip install -r samples/requirements.txt
3837
pylint --disable=missing-function-docstring,missing-class-docstring samples tests

MANIFEST.in

Lines changed: 0 additions & 6 deletions
This file was deleted.

cspell.config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ignorePaths:
1212
- '.*'
1313
- 'build'
1414
- 'docs'
15-
- 'dev_requirements.txt'
15+
- 'node_modules'
1616
- '*.egg-info'
1717
- '*.ini'
1818
- '*.toml'

dev_requirements.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

featuremanagement/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# -------------------------------------------------------------------------
6+
"""Feature management library for Python."""
7+
68
from ._featuremanager import FeatureManager
79
from ._featurefilters import FeatureFilter
810
from ._defaultfilters import TimeWindowFilter, TargetingFilter

featuremanagement/_defaultfilters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# -------------------------------------------------------------------------
6+
"""Built-in feature filter implementations."""
7+
68
import logging
79
import hashlib
810
from datetime import datetime, timezone

featuremanagement/_featurefilters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# -------------------------------------------------------------------------
6+
"""Base class for feature filters."""
7+
68
from abc import ABC, abstractmethod
79
from typing import Mapping, Callable, Any, Optional
810

featuremanagement/_featuremanager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# -------------------------------------------------------------------------
6+
"""Synchronous feature manager implementation."""
7+
68
import logging
79
from typing import cast, overload, Any, Optional, Dict, Mapping, List, Tuple
810
from ._defaultfilters import TimeWindowFilter, TargetingFilter

featuremanagement/_featuremanagerbase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# -------------------------------------------------------------------------
6+
"""Base class for feature manager implementations."""
7+
68
import hashlib
79
import logging
810
from abc import ABC

0 commit comments

Comments
 (0)