Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
codexctl/device.py (1)
514-519: Consider extracting the SFTPexistshelper to avoid a third copy.This is the third near-identical
file_exists/existshelper in the module (see_read_version_from_pathat line 309 and_get_paper_pro_partition_infoat line 459). Extracting a small private method like_sftp_exists(ftp, path)would eliminate the duplication and keep behavior (exception types caught) consistent across call sites.♻️ Sketch
+ `@staticmethod` + def _sftp_exists(ftp, path: str) -> bool: + try: + ftp.stat(path) + return True + except (FileNotFoundError, IOError): + return FalseThen at line 514:
- def exists(path:str) -> bool: - try: - _ = ftp.stat(path) - return True - except (FileNotFoundError, IOError): - return False + exists = lambda p: self._sftp_exists(ftp, p)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@codexctl/device.py` around lines 514 - 519, Extract the duplicated SFTP existence check into a single private helper (e.g. _sftp_exists(ftp, path)) and replace the three local helpers (the exists defined near line 514, the file_exists/_read_version_from_path helper around line 309, and the helper used in _get_paper_pro_partition_info around line 459) to call this new function; the helper should accept the FTP/SFTP client and path, try ftp.stat(path) and return True, and catch the same exceptions currently used (FileNotFoundError, IOError) to return False so behavior remains consistent across call sites.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@codexctl/device.py`:
- Around line 514-519: Extract the duplicated SFTP existence check into a single
private helper (e.g. _sftp_exists(ftp, path)) and replace the three local
helpers (the exists defined near line 514, the
file_exists/_read_version_from_path helper around line 309, and the helper used
in _get_paper_pro_partition_info around line 459) to call this new function; the
helper should accept the FTP/SFTP client and path, try ftp.stat(path) and return
True, and catch the same exceptions currently used (FileNotFoundError, IOError)
to return False so behavior remains consistent across call sites.
Summary by CodeRabbit