Skip to content

Commit 10de0c4

Browse files
samuellawerentzclaude
authored andcommitted
refactor(plugins): simplify settings resolution helpers
- Drop redundant except FileNotFoundError in _read_block (subclass of Exception, already caught). - Drop redundant os.path.abspath in load_settings; _project_dir already returns an absolute path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Samuel Lawrentz <samuel.lawerence@plivo.com>
1 parent a9abaae commit 10de0c4

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

plugins/claude-code/hooks/pre-compact.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def _read_block(path):
6868
try:
6969
with open(path) as fh:
7070
block = json.load(fh).get("basicMemory")
71-
except FileNotFoundError:
72-
return None
7371
except Exception:
7472
return None
7573
return block if isinstance(block, dict) else None
@@ -97,8 +95,8 @@ def load_settings(directory):
9795
merged = {}
9896
home = os.path.expanduser("~")
9997
sources = [(home, ("settings.json",))]
100-
project = _project_dir(directory)
101-
if os.path.abspath(project) != home:
98+
project = _project_dir(directory) # already absolute
99+
if project != home:
102100
sources.append((project, ("settings.json", "settings.local.json")))
103101
for d, names in sources:
104102
for name in names:

plugins/claude-code/hooks/session-start.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ def _read_block(path):
9090
try:
9191
with open(path) as fh:
9292
block = json.load(fh).get("basicMemory")
93-
except FileNotFoundError:
94-
return None
9593
except Exception:
9694
return None
9795
return block if isinstance(block, dict) else None
@@ -115,8 +113,8 @@ def load_settings(directory):
115113
found = False
116114
home = os.path.expanduser("~")
117115
sources = [(home, ("settings.json",))]
118-
project = _project_dir(directory)
119-
if os.path.abspath(project) != home:
116+
project = _project_dir(directory) # already absolute
117+
if project != home:
120118
sources.append((project, ("settings.json", "settings.local.json")))
121119
for d, names in sources:
122120
for name in names:

0 commit comments

Comments
 (0)