fix: pin black to 26.3.1 across all environments
- Pin black version in requirements-dev.txt (was >=24.0.0) - Update pre-commit to use black 26.3.1 with Python 3.12 - Add language_version: python3.12 to pre-commit black hook - Reformat files with new black version for consistency
This commit is contained in:
@@ -13,11 +13,9 @@ def _ensure_lightweight_charts_assets() -> None:
|
||||
global _CHARTS_SCRIPT_ADDED
|
||||
if _CHARTS_SCRIPT_ADDED:
|
||||
return
|
||||
ui.add_head_html(
|
||||
"""
|
||||
ui.add_head_html("""
|
||||
<script src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script>
|
||||
"""
|
||||
)
|
||||
""")
|
||||
_CHARTS_SCRIPT_ADDED = True
|
||||
|
||||
|
||||
@@ -48,8 +46,7 @@ class CandlestickChart:
|
||||
self._initialize_chart()
|
||||
|
||||
def _initialize_chart(self) -> None:
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const root = document.getElementById({json.dumps(self.chart_id)});
|
||||
if (!root || typeof LightweightCharts === 'undefined') return;
|
||||
@@ -94,57 +91,48 @@ class CandlestickChart:
|
||||
indicators: {{}},
|
||||
}};
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def set_candles(self, candles: list[dict[str, Any]]) -> None:
|
||||
payload = json.dumps(candles)
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const ref = window.vaultDashCharts?.[{json.dumps(self.chart_id)}];
|
||||
if (!ref) return;
|
||||
ref.candleSeries.setData({payload});
|
||||
ref.chart.timeScale().fitContent();
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def update_price(self, candle: dict[str, Any]) -> None:
|
||||
payload = json.dumps(candle)
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const ref = window.vaultDashCharts?.[{json.dumps(self.chart_id)}];
|
||||
if (!ref) return;
|
||||
ref.candleSeries.update({payload});
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def set_volume(self, volume_points: list[dict[str, Any]]) -> None:
|
||||
payload = json.dumps(volume_points)
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const ref = window.vaultDashCharts?.[{json.dumps(self.chart_id)}];
|
||||
if (!ref) return;
|
||||
ref.volumeSeries.setData({payload});
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def update_volume(self, volume_point: dict[str, Any]) -> None:
|
||||
payload = json.dumps(volume_point)
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const ref = window.vaultDashCharts?.[{json.dumps(self.chart_id)}];
|
||||
if (!ref) return;
|
||||
ref.volumeSeries.update({payload});
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def set_indicator(
|
||||
self,
|
||||
@@ -156,8 +144,7 @@ class CandlestickChart:
|
||||
) -> None:
|
||||
key = json.dumps(name)
|
||||
payload = json.dumps(points)
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const ref = window.vaultDashCharts?.[{json.dumps(self.chart_id)}];
|
||||
if (!ref) return;
|
||||
@@ -171,19 +158,16 @@ class CandlestickChart:
|
||||
}}
|
||||
ref.indicators[{key}].setData({payload});
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
def update_indicator(self, name: str, point: dict[str, Any]) -> None:
|
||||
key = json.dumps(name)
|
||||
payload = json.dumps(point)
|
||||
ui.run_javascript(
|
||||
f"""
|
||||
ui.run_javascript(f"""
|
||||
(function() {{
|
||||
const ref = window.vaultDashCharts?.[{json.dumps(self.chart_id)}];
|
||||
const series = ref?.indicators?.[{key}];
|
||||
if (!series) return;
|
||||
series.update({payload});
|
||||
}})();
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -117,8 +117,7 @@ class StrategyComparisonPanel:
|
||||
scenario_class = (
|
||||
"text-emerald-600 dark:text-emerald-400" if scenario >= 0 else "text-rose-600 dark:text-rose-400"
|
||||
)
|
||||
rows.append(
|
||||
f"""
|
||||
rows.append(f"""
|
||||
<tr class=\"border-b border-slate-200 dark:border-slate-800\">
|
||||
<td class=\"px-4 py-3 font-medium text-slate-900 dark:text-slate-100\">{name}</td>
|
||||
<td class=\"px-4 py-3 text-slate-600 dark:text-slate-300\">${cost:,.2f}</td>
|
||||
@@ -126,8 +125,7 @@ class StrategyComparisonPanel:
|
||||
<td class=\"px-4 py-3 text-slate-600 dark:text-slate-300\">{self._format_cap(strategy)}</td>
|
||||
<td class=\"px-4 py-3 font-semibold {scenario_class}\">${scenario:,.2f}</td>
|
||||
</tr>
|
||||
"""
|
||||
)
|
||||
""")
|
||||
return f"""
|
||||
<div class=\"overflow-x-auto\">
|
||||
<table class=\"min-w-full rounded-xl overflow-hidden\">
|
||||
|
||||
@@ -137,8 +137,7 @@ async def options_page() -> None:
|
||||
</thead>
|
||||
<tbody>
|
||||
"""
|
||||
+ "".join(
|
||||
f"""
|
||||
+ "".join(f"""
|
||||
<tr class='border-b border-slate-200 dark:border-slate-800'>
|
||||
<td class='px-4 py-3 font-medium text-slate-900 dark:text-slate-100'>{row['symbol']}</td>
|
||||
<td class='px-4 py-3 text-slate-600 dark:text-slate-300'>{row['type'].upper()}</td>
|
||||
@@ -149,9 +148,7 @@ async def options_page() -> None:
|
||||
<td class='px-4 py-3 text-slate-600 dark:text-slate-300'>Δ {float(row.get('delta', 0.0)):+.3f} · Γ {float(row.get('gamma', 0.0)):.3f} · Θ {float(row.get('theta', 0.0)):+.3f} · V {float(row.get('vega', 0.0)):.3f}</td>
|
||||
<td class='px-4 py-3 text-sky-600 dark:text-sky-300'>Use quick-add buttons below</td>
|
||||
</tr>
|
||||
"""
|
||||
for row in rows
|
||||
)
|
||||
""" for row in rows)
|
||||
+ (
|
||||
""
|
||||
if rows
|
||||
|
||||
@@ -124,13 +124,11 @@ def welcome_page(request: Request):
|
||||
if turnstile.uses_test_keys
|
||||
else ""
|
||||
)
|
||||
ui.html(
|
||||
f"""<form method="post" action="/workspaces/bootstrap" class="flex items-center gap-4">
|
||||
ui.html(f"""<form method="post" action="/workspaces/bootstrap" class="flex items-center gap-4">
|
||||
{hidden_token}
|
||||
<div class="cf-turnstile" data-sitekey="{turnstile.site_key}"></div>
|
||||
<button type="submit" class="rounded-lg bg-slate-900 px-5 py-3 text-sm font-semibold text-white no-underline dark:bg-slate-100 dark:text-slate-900">Get started</button>
|
||||
</form>"""
|
||||
)
|
||||
</form>""")
|
||||
ui.label("You can always create a fresh workspace later if a link is lost.").classes(
|
||||
"text-sm text-slate-500 dark:text-slate-400"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user