Skip to content

Commit 3c1d5e6

Browse files
GeneAIclaude
authored andcommitted
fix: Use X | Y syntax in isinstance calls (UP038)
Update isinstance calls to use modern Python 3.10+ union syntax instead of tuple syntax for better readability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b5c5b7b commit 3c1d5e6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/empathy_os/memory/short_term.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ def stream_append(
16241624
"agent_id": credentials.agent_id,
16251625
"timestamp": datetime.now().isoformat(),
16261626
**{
1627-
str(k): json.dumps(v) if isinstance(v, (dict, list)) else str(v)
1627+
str(k): json.dumps(v) if isinstance(v, dict | list) else str(v)
16281628
for k, v in data.items()
16291629
},
16301630
}

src/empathy_os/project_index/scanner.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ def _analyze_python_ast(self, tree: ast.AST) -> dict[str, Any]:
361361

362362
for node in ast.walk(tree):
363363
# Check for docstrings
364-
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef, ast.Module)):
364+
if isinstance(node, ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef | ast.Module):
365365
if ast.get_docstring(node):
366366
result["has_docstrings"] = True
367367

368368
# Check for type hints
369-
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
369+
if isinstance(node, ast.FunctionDef | ast.AsyncFunctionDef):
370370
if node.returns or any(arg.annotation for arg in node.args.args):
371371
result["has_type_hints"] = True
372372

@@ -376,7 +376,9 @@ def _analyze_python_ast(self, tree: ast.AST) -> dict[str, Any]:
376376

377377
# Simple complexity: count branches
378378
for child in ast.walk(node):
379-
if isinstance(child, (ast.If, ast.For, ast.While, ast.Try, ast.ExceptHandler)):
379+
if isinstance(
380+
child, ast.If | ast.For | ast.While | ast.Try | ast.ExceptHandler
381+
):
380382
result["complexity"] += 1.0
381383

382384
# Track imports

0 commit comments

Comments
 (0)