Skip to content

Commit b29b29a

Browse files
committed
Pylint fixes
1 parent 8247dce commit b29b29a

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/venv
2-
scripts/__pycache__
2+
scripts/__pycache__
3+
.mypy_cache/

app.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323
import os
2424
import pathlib
25-
import starplot
26-
import streamlit as st
2725
from datetime import datetime, date
2826
from zoneinfo import ZoneInfo
2927

28+
import streamlit as st
29+
30+
import starplot
3031
import starplot.data.constellations as condata
3132
import starplot.data.stars as stardata
3233

@@ -44,7 +45,7 @@
4445
try:
4546
condata.table()
4647
stardata.table()
47-
except Exception as e:
48+
except Exception as e: # pylint: disable=broad-exception-caught
4849
print("Warning: preload failed:", e)
4950

5051
# ───────────────────────────────────────────────
@@ -61,7 +62,7 @@
6162

6263
# Extra option: fast vs HD
6364
quality = st.sidebar.radio("Quality", ["Fast (preview)", "HD (slower)"])
64-
resolution = 1200 if quality == "Fast (preview)" else 2400
65+
RESOLUTION = 1200 if quality == "Fast (preview)" else 2400
6566

6667
# Session state
6768
if "chart_bytes" not in st.session_state:
@@ -72,11 +73,26 @@
7273
# Cached chart generator
7374
# ───────────────────────────────────────────────
7475
@st.cache_data
75-
def generate_chart(plot_type, dt, mag_limit, resolution):
76-
if plot_type == "Horizon":
77-
return make_horizon_plot(dt=dt, mag_limit=mag_limit, resolution=resolution)
78-
else:
79-
return make_zenith_plot(dt=dt, mag_limit=mag_limit, resolution=resolution)
76+
def generate_chart(plt_type: str,
77+
date_time: datetime,
78+
mag_lim: int,
79+
res: int) -> bytes:
80+
"""
81+
Generate chart and cache for performance
82+
83+
Args:
84+
- plt_type: Either Horizon or Zenith
85+
- date_time: Datetime for the star plot
86+
- mag_lim: The maximum magnitude for stars in the plot
87+
- res: Resolution of the image
88+
89+
Returns:
90+
- The image in bytes
91+
"""
92+
if plt_type == "Horizon":
93+
return make_horizon_plot(dt=date_time, mag_limit=mag_lim, resolution=res)
94+
95+
return make_zenith_plot(dt=date_time, mag_limit=mag_lim, resolution=res)
8096

8197

8298
# ───────────────────────────────────────────────
@@ -87,7 +103,7 @@ def generate_chart(plot_type, dt, mag_limit, resolution):
87103
dt = datetime.combine(obs_date, obs_time).replace(tzinfo=tz)
88104

89105
with st.spinner("Generating chart, please wait..."):
90-
img_bytes = generate_chart(plot_type, dt, mag_limit, resolution)
106+
img_bytes = generate_chart(plot_type, dt, mag_limit, RESOLUTION)
91107

92108
st.session_state.chart_bytes = img_bytes
93109
st.success("✅ Chart generated!")

scripts/glasgow_zenith.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,3 @@ def make_zenith_plot(
8484
buf.seek(0)
8585

8686
return buf.getvalue()
87-

0 commit comments

Comments
 (0)