microsoft / microsoft/FeatureManagement-Python
Typing bug in FeatureManager.is_enabled overloads: single argument call not supported by type hints
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 26
- Fork
- 11
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
- Package Version: 2.1.0
- Operating System: Ubuntu
- Python Version: 3.12
Describe the bug
The FeatureManager.is_enabled method has incorrect type hints in the published SDK.
The implementation accepts a single argument:
await feature_manager.is_enabled("my-flag")
This works at runtime because the method signature is:
async def is_enabled(self, feature_flag_id: str, *args, **kwargs) -> bool
However, the declared overloads do not include a signature that accepts only one argument. The only available overload is:
@overload
async def is_enabled(self, feature_flag_id: str, user_id: str, **kwargs) -> bool:
...
Type checkers such as Mypy report this usage as invalid and treat the return type as Any.
Expected Behavior
The type hints should describe all valid usages. Since the runtime implementation allows calling the method with only feature_flag_id, the overloads should include a matching variant.
Proposed Fix
Add a second overload:
@overload
async def is_enabled(self, feature_flag_id: str) -> bool:
...
This aligns the type hints with the implementation and returns the correct bool type to static analysis tools.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Xác định các khai báo overload của FeatureManager.is_enabled và so sánh chúng với chữ ký runtime cũng như ví dụ một đối số trong issue này. Thêm biến thể typing một đối số còn thiếu, sau đó xác minh rằng phân tích tĩnh chấp nhận lời gọi và suy luận bool.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- developer-experience
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 55/100