Two location guards test presence rather than lock, so alt/az can be computed at 0,0
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- python
- 领域
- embedded-iot
调研方向
首先阅读 python/PiFinder/calc_utils.py 和 python/PiFinder/integrator.py,然后检查 python/PiFinder/state.py 中的 Location 默认值和锁定逻辑。追踪这两个调用点及其相关测试套件;完成的标准是两者都拒绝未锁定的位置(并防御性地处理 None),且不改变 Location 的真假值或时区行为。
由索引模型根据 Issue 内容生成。
描述
Found while verifying the wording for #646 (docs PR #653). Latent — no user-visible symptom today — but the guards do not express what they are trying to express, and the thing masking them is upstream and unrelated.
The problem
Two call sites guard on the presence of a Location when what they need is a locked one.
python/PiFinder/calc_utils.py:243 — calc_object_altitude():
location = shared_state.location()
dt = shared_state.datetime()
if location and dt and solution:
aa = FastAltAz(location.lat, location.lon, dt)
python/PiFinder/integrator.py:493 — _get_alt_az():
if ra_deg is None or dec_deg is None or location is None or dt is None:
return None, None
calc_utils.sf_utils.set_location(location.lat, location.lon, location.altitude)
Why neither guard does anything
Location is a plain @dataclass (state.py:196) with no __bool__ and no __len__, so every instance is truthy. And the field is initialized to a real object, not None:
self.__location: Location = Location() # state.py:295
whose defaults are lat = 0.0, lon = 0.0, lock = False. So if location is always true, and location is None is essentially always false.
The guards therefore reduce to if dt and solution and if ra/dec and dt. A path that sets a datetime without a lock computes alt/az for an observer at 0°N 0°E — Null Island, in the Gulf of Guinea. The result is a plausible-looking number that is wrong by however far the user is from there.
Why nothing breaks today
Both are reached through UI paths already gated on shared_state.altaz_ready() (state.py:332), which does test location.lock. The masking is upstream and incidental — nothing in either function records that it depends on a caller checking lock first.
Suggested fix
Guard on location.lock at both sites, matching altaz_ready(). Defining __bool__ on Location to mean "locked" would make the existing if location read correctly, but that is a wider change with its own trap: if location would then be false for a perfectly valid unlocked Location, and state.py:544 (if self.__location and self.__location.timezone) relies on current truthiness for timezone resolution, which has nothing to do with lock. Explicit location.lock at the two call sites is the smaller and clearer change.
Note set_location() (state.py:471) does assign v unconditionally, so None is technically reachable through it. Keeping a None check alongside a lock check is defensible; testing only for None is not.
- 主要语言
- Jupyter Notebook
- 星标
- 253
- 派生
- 63
- 平均合并
- 11 小时 55 分钟
- 30 天内合并 PR
- 8
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
brickbots/PiFinder 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 67/100
brickbots/PiFinder#682 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
catalogs enhancement
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
查看 brickbots/PiFinder 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
zephyrproject-rtos/zephyr#123881 ·
维护者通常 2 天内回复
-
hw-verify platform:k2
难度 2/5 1-3 小时 新手友好度 65/100
prestonbrown/helixscreen#1933 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100