Skip to content

Commit 704f0b3

Browse files
committed
fix: ruff linting errors in interactive eval mode
- Move imports to top of file - Replace all bare except clauses with Exception - Remove unused f-string prefixes - Fix import organization
1 parent 073041d commit 704f0b3

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

src/uipath/_cli/_eval_interactive.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,24 @@
33
import json
44
import subprocess
55
import sys
6+
import termios
7+
import tty
68
from pathlib import Path
79
from typing import Any, Dict, List, Optional, Tuple
810

9-
import select
10-
import sys
11-
import termios
12-
import tty
11+
from ._utils._console import ConsoleLogger
12+
1313

1414
def has_termios() -> bool:
1515
"""Check if we have termios support for advanced input."""
1616
try:
1717
termios.tcgetattr(sys.stdin)
1818
return True
19-
except:
19+
except Exception:
2020
return False
2121

22-
HAS_NAVIGATION = has_termios()
23-
24-
from ._utils._console import ConsoleLogger
2522

23+
HAS_NAVIGATION = has_termios()
2624
console = ConsoleLogger()
2725

2826

@@ -76,7 +74,7 @@ def _discover_files(self) -> None:
7674
if "evaluations" in data and isinstance(data.get("evaluations"), list):
7775
name = data.get("name", eval_file.stem)
7876
self.eval_sets.append((name, eval_file))
79-
except:
77+
except Exception:
8078
pass
8179

8280
# Find evaluators from evaluators folder
@@ -90,7 +88,7 @@ def _discover_files(self) -> None:
9088
if "id" in data and "type" in data:
9189
name = data.get("name", eval_file.stem)
9290
self.evaluators.append((name, eval_file))
93-
except:
91+
except Exception:
9492
pass
9593

9694
def run(self) -> None:
@@ -220,13 +218,13 @@ def _get_key_input(self) -> str:
220218
raise KeyboardInterrupt
221219

222220
return ''
223-
except:
221+
except Exception:
224222
return input("➤ ").strip().lower()
225223
finally:
226224
# Restore terminal settings
227225
try:
228226
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
229-
except:
227+
except Exception:
230228
pass
231229

232230
def _execute_menu_item_with_navigation(self, index: int) -> None:
@@ -291,7 +289,7 @@ def _list_eval_sets(self) -> None:
291289
console.info(f"{i}. {name}")
292290
console.info(f" Tests: {test_count} | Evaluators: {evaluator_count}")
293291
console.info(f" File: {path.name}")
294-
except:
292+
except Exception:
295293
console.info(f"{i}. {name} (error loading)")
296294

297295
def _list_evaluators(self) -> None:
@@ -310,7 +308,7 @@ def _list_evaluators(self) -> None:
310308
console.info(f"{i}. {name}")
311309
console.info(f" Type: {category} | {type_name}")
312310
console.info(f" File: {path.name}")
313-
except:
311+
except Exception:
314312
console.info(f"{i}. {name} (error loading)")
315313

316314
def _list_eval_sets_navigation(self) -> None:
@@ -652,7 +650,7 @@ def _show_no_items_screen(self, item_type: str) -> None:
652650
"""Show no items screen."""
653651
self._clear_screen()
654652
console.warning(f"No {item_type} found!")
655-
console.info(f"Press Enter to go back...")
653+
console.info("Press Enter to go back...")
656654
self._get_input("")
657655

658656
def _show_eval_set_preview(self, path: Path) -> None:
@@ -664,7 +662,7 @@ def _show_eval_set_preview(self, path: Path) -> None:
664662
evaluator_count = len(data.get("evaluatorRefs", []))
665663
console.info(f" 📄 {path.name}")
666664
console.info(f" 📊 Tests: {test_count} | Evaluators: {evaluator_count}")
667-
except:
665+
except Exception:
668666
console.info(f" 📄 {path.name} (error loading)")
669667

670668
def _show_evaluator_preview(self, path: Path) -> None:
@@ -676,7 +674,7 @@ def _show_evaluator_preview(self, path: Path) -> None:
676674
type_name = self._get_type_name(data.get("type", 1))
677675
console.info(f" 📄 {path.name}")
678676
console.info(f" 🎯 Type: {category} | {type_name}")
679-
except:
677+
except Exception:
680678
console.info(f" 📄 {path.name} (error loading)")
681679

682680
def _show_eval_set_details(self, eval_set_tuple: Tuple[str, Path]) -> None:
@@ -699,13 +697,13 @@ def _show_eval_set_details(self, eval_set_tuple: Tuple[str, Path]) -> None:
699697

700698
evaluator_refs = data.get('evaluatorRefs', [])
701699
if evaluator_refs:
702-
console.info(f"\n🎯 Evaluator References:")
700+
console.info("\n🎯 Evaluator References:")
703701
for ref in evaluator_refs:
704702
console.info(f" • {ref}")
705703

706704
evaluations = data.get('evaluations', [])
707705
if evaluations:
708-
console.info(f"\n📝 Test Cases:")
706+
console.info("\n📝 Test Cases:")
709707
for i, eval_data in enumerate(evaluations[:10], 1): # Show first 10
710708
test_name = eval_data.get('name', f'Test {i}')
711709
console.info(f" {i}. {test_name}")
@@ -752,7 +750,7 @@ def _show_evaluator_details(self, evaluator_tuple: Tuple[str, Path]) -> None:
752750

753751
if 'llmConfig' in data:
754752
llm_config = data['llmConfig']
755-
console.info(f"\n🤖 LLM Configuration:")
753+
console.info("\n🤖 LLM Configuration:")
756754
console.info(f" Model: {llm_config.get('modelName', 'Unknown')}")
757755
if 'prompt' in llm_config:
758756
prompt_preview = llm_config['prompt'][:100]
@@ -1115,7 +1113,7 @@ def _create_evaluator_interactive(self) -> None:
11151113
eval_type = 1
11161114

11171115
# Target Output Key
1118-
console.info(f"\n🔍 Target Configuration")
1116+
console.info("\n🔍 Target Configuration")
11191117
console.info("Target Output Key determines which part of the output to evaluate")
11201118
console.info("Examples: '*' (all), 'result', 'answer', 'output'")
11211119
target_key = input("➤ Target Output Key (default: '*'): ").strip() or "*"
@@ -1134,7 +1132,7 @@ def _create_evaluator_interactive(self) -> None:
11341132

11351133
# LLM Configuration (if LLM as Judge)
11361134
if category == 1: # LLM as Judge
1137-
console.info(f"\n🤖 LLM Configuration")
1135+
console.info("\n🤖 LLM Configuration")
11381136
model_name = input("➤ Model Name (default: gpt-4): ").strip() or "gpt-4"
11391137

11401138
console.info("📝 Evaluation Prompt")
@@ -1191,7 +1189,7 @@ def _get_evaluator_id(self, path: Path) -> str:
11911189
with open(path) as f:
11921190
data = json.load(f)
11931191
return data.get("id", path.stem)
1194-
except:
1192+
except Exception:
11951193
return path.stem
11961194

11971195

0 commit comments

Comments
 (0)