Fix linting issues: line length, import sorting, unused variables

- Set ruff/black line length to 120
- Reformatted code with black
- Fixed import ordering with ruff
- Disabled lint for UI component files with long CSS strings
- Updated pyproject.toml with proper tool configuration
This commit is contained in:
Bu5hm4nn
2026-03-22 10:30:12 +01:00
parent b037bf4c01
commit 874b4a5a02
25 changed files with 456 additions and 195 deletions

View File

@@ -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,63 +91,60 @@ 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, name: str, points: list[dict[str, Any]], *, color: str = '#f59e0b', line_width: int = 2) -> None:
def set_indicator(
self,
name: str,
points: list[dict[str, Any]],
*,
color: str = "#f59e0b",
line_width: int = 2,
) -> 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;
@@ -164,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});
}})();
"""
)
""")