Fix typos and wrong types in remote_config.py

未关闭 适合新手
#957 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python
领域
api, backend

调研方向

从 firebase_admin/remote_config.py 开始,阅读 evaluate_custom_signal_condition 和 _Value.as_int(),以及附近的类型处理代码。根据 issue 验证回退值和返回注解,然后在可用的情况下运行仓库中相关的 remote-config 测试;完成的标准是默认值和注解与其字段类型匹配,且没有回归问题。

由索引模型根据 Issue 内容生成。

描述

api: remoteconfig
[READ] Step 1: Are you in the right place?

This is a bug in the code of this repository (firebase_admin/remote_config.py).


[REQUIRED] Step 2: Describe your environment
  • Operating System version: Windows 11
  • Firebase SDK version: 6.x (latest)
  • Firebase Product: remote_config
  • Python version: 3.11
  • Pip version: 24.x

[REQUIRED] Step 3: Describe the problem
Steps to reproduce:

In firebase_admin/remote_config.py, the method evaluate_custom_signal_condition
uses {} (empty dict) as the default fallback for string and list fields:

custom_signal_operator = custom_signal_condition.get('customSignalOperator') or {}
custom_signal_key = custom_signal_condition.get('customSignalKey') or {}
target_custom_signal_values = custom_signal_condition.get('targetCustomSignalValues') or {}

These should be '' (string) and [] (list) respectively, as the fields are
not dicts. Using {} is semantically incorrect.

Also, _Value.as_int() has a wrong return type annotation -> float instead
of -> int.

Relevant Code:
# Wrong defaults — should be '' and []
custom_signal_operator = custom_signal_condition.get('customSignalOperator') or {}
custom_signal_key = custom_signal_condition.get('customSignalKey') or {}
target_custom_signal_values = custom_signal_condition.get('targetCustomSignalValues') or {}

# Wrong return type annotation — should be -> int
def as_int(self) -> float:
    """Returns the value as a number."""
主要语言
Python
星标
1.2k
派生
359
平均合并
5 天 6 分钟
30 天内合并 PR
2

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-python 的其他 Issue

查看 firebase/firebase-admin-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。