Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Two location guards test presence rather than lock, so alt/az can be computed at 0,0

Aperta Adatta ai principianti
#656 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
embedded-iot

Direzione di ricerca

Inizia con python/PiFinder/calc_utils.py e python/PiFinder/integrator.py, quindi esamina i valori predefiniti di Location e la logica di blocco in python/PiFinder/state.py. Traccia i due punti di chiamata e le relative suite di test; il completamento significa che entrambi rifiutano una posizione non bloccata (e gestiscono None in modo difensivo) senza modificare la truthiness o il comportamento del fuso orario di Location.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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.

Lingua principale
Jupyter Notebook
Stelle
253
Fork
63
Merge medio
11h 55m
PR unite (30g)
8

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di brickbots/PiFinder

Tutte le issue di brickbots/PiFinder

Issue simili

Altre issue su Embedded & IoT

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.