From c6a90aa7ea3fdd99d5e3438d349c81d004f9bd07 Mon Sep 17 00:00:00 2001 From: Ibrahim Elsayed Date: Mon, 18 May 2026 18:57:26 +0300 Subject: [PATCH 1/3] fix: Replace 14 bare except blocks in pt_hub.py with specific types GUI tab creation bare excepts (lines 4303-4638): except Exception: Process communicate timeout (line 5548): except (TimeoutError, OSError): Stdout read failure (line 5597): except (OSError, AttributeError): Widget/color utilities (lines 5680-5906): except Exception: Bare except: swallows SystemExit and KeyboardInterrupt. All 14 replaced. pt_trader.py had 0 bare except: (only broad except Exception: which is acceptable given its error handling patterns). --- app/pt_hub.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/pt_hub.py b/app/pt_hub.py index 876a6776..988a1b0b 100644 --- a/app/pt_hub.py +++ b/app/pt_hub.py @@ -4302,7 +4302,7 @@ def _create_llm_research_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating LLM Research tab: {e}") import traceback @@ -4343,7 +4343,7 @@ def _create_holdings_management_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Holdings Management tab: {e}") import traceback @@ -4384,7 +4384,7 @@ def _create_portfolio_analytics_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Portfolio Analytics tab: {e}") import traceback @@ -4425,7 +4425,7 @@ def _create_advanced_order_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Advanced Order Types tab: {e}") import traceback @@ -4466,7 +4466,7 @@ def _create_market_data_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Real-time Market Data tab: {e}") import traceback @@ -4510,7 +4510,7 @@ def _create_portfolio_optimization_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Portfolio Optimization tab: {e}") import traceback @@ -4551,7 +4551,7 @@ def _create_backtesting_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Backtesting Framework tab: {e}") import traceback @@ -4596,7 +4596,7 @@ def _create_performance_attribution_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Performance Attribution tab: {e}") import traceback @@ -4637,7 +4637,7 @@ def _create_institutional_trading_tab(self): font=("TkDefaultFont", 10), anchor="center", ).pack(expand=True, fill="both", padx=20, pady=20) - except: + except Exception: pass print(f"Error creating Institutional Trading tab: {e}") import traceback @@ -5549,7 +5549,7 @@ def start_trainer_for_selected_coin(self) -> None: print(f"DEBUG: Process output: {stdout}") if stderr: print(f"DEBUG: Process stderr: {stderr}") - except: + except (TimeoutError, OSError): pass return # Don't register a failed process @@ -5598,7 +5598,7 @@ def _monitor_trainer_process(self, coin: str) -> None: print( f"DEBUG: Final output from {coin}: {remaining_output}" ) - except: + except (OSError, AttributeError): pass else: # Process still running, check again in 2 seconds @@ -5681,7 +5681,7 @@ def _create_crypto_icon_grid( # Ensure we get 3 coins in normal view, 4-5 in fullscreen if max_cols < 3: max_cols = 3 - except: + except Exception: max_cols = 3 # Default to 3 for better wrapping row = 0 @@ -5770,7 +5770,7 @@ def on_enter(event): frame.configure(relief="raised", bd=3) else: frame.configure(relief="raised", bd=3) - except: + except Exception: frame.configure(relief="raised", bd=3) def on_leave(event): @@ -5907,7 +5907,7 @@ def on_coin_click(event=None): "Training Error", f"Failed {action} training for {coin_name}: {e}", ) - except: + except Exception: pass return on_coin_click From e37c21dca4fa13edfe88ac9cf9350a2f6ef8ac7e Mon Sep 17 00:00:00 2001 From: Ibrahim Elsayed Date: Mon, 18 May 2026 21:37:49 +0300 Subject: [PATCH 2/3] fix: Black formatting on pt_hub.py --- app/pt_hub.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/pt_hub.py b/app/pt_hub.py index 988a1b0b..aec6bd08 100644 --- a/app/pt_hub.py +++ b/app/pt_hub.py @@ -8105,9 +8105,9 @@ def do_save(): if len(raw) == 64: raw = raw[:32] priv_b64 = base64.b64encode(raw).decode("utf-8") - private_b64_state["value"] = ( - priv_b64 # keep UI state consistent - ) + private_b64_state[ + "value" + ] = priv_b64 # keep UI state consistent elif len(raw) != 32: messagebox.showerror( "Bad private key", @@ -8422,9 +8422,9 @@ def save(): self.settings["auto_best_price"] = bool(auto_best_price_var.get()) self.settings["script_neural_runner2"] = neural_script_var.get().strip() - self.settings["script_neural_trainer"] = ( - trainer_script_var.get().strip() - ) + self.settings[ + "script_neural_trainer" + ] = trainer_script_var.get().strip() self.settings["script_trader"] = trader_script_var.get().strip() self.settings["ui_refresh_seconds"] = float( From 060088c6952148bffb478ae735f788f5fc489c31 Mon Sep 17 00:00:00 2001 From: Ibrahim Elsayed Date: Tue, 19 May 2026 15:29:35 +0300 Subject: [PATCH 3/3] style: apply Black formatting to pt_hub.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Black check failed in CI — pt_hub.py had formatting issues. Auto-formatted with Black. --- app/pt_hub.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/pt_hub.py b/app/pt_hub.py index aec6bd08..988a1b0b 100644 --- a/app/pt_hub.py +++ b/app/pt_hub.py @@ -8105,9 +8105,9 @@ def do_save(): if len(raw) == 64: raw = raw[:32] priv_b64 = base64.b64encode(raw).decode("utf-8") - private_b64_state[ - "value" - ] = priv_b64 # keep UI state consistent + private_b64_state["value"] = ( + priv_b64 # keep UI state consistent + ) elif len(raw) != 32: messagebox.showerror( "Bad private key", @@ -8422,9 +8422,9 @@ def save(): self.settings["auto_best_price"] = bool(auto_best_price_var.get()) self.settings["script_neural_runner2"] = neural_script_var.get().strip() - self.settings[ - "script_neural_trainer" - ] = trainer_script_var.get().strip() + self.settings["script_neural_trainer"] = ( + trainer_script_var.get().strip() + ) self.settings["script_trader"] = trader_script_var.get().strip() self.settings["ui_refresh_seconds"] = float(