skills/code-review/python-quality-review/SKILL.md
Python-specific code review focusing on idiomatic patterns, type hints, async correctness, and Python best practices. Use for reviewing Python code, ensuring Pythonic patterns, catching Python-specific pitfalls, and maintaining Python code quality.
npx skillsauth add simplerick0/com.ackhax.configs python-quality-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Review Python code for idiomatic patterns, correctness, and best practices.
# Missing type hints
def process(data):
return data.get('value')
# With type hints
def process(data: dict[str, Any]) -> str | None:
return data.get('value')
# Bug: Mutable default (shared across calls)
def append_to(item, target=[]):
target.append(item)
return target
# Fixed: Use None default
def append_to(item, target: list | None = None):
if target is None:
target = []
target.append(item)
return target
# Too broad
try:
result = process(data)
except Exception:
pass # Silently swallows all errors
# Better: Specific exceptions
try:
result = process(data)
except ValidationError as e:
logger.warning(f"Validation failed: {e}")
return None
except ConnectionError as e:
logger.error(f"Connection failed: {e}")
raise
# Non-Pythonic
result = []
for item in items:
if item.is_valid:
result.append(item.value)
# Pythonic
result = [item.value for item in items if item.is_valid]
# Bad: Manual resource management
f = open('file.txt')
try:
data = f.read()
finally:
f.close()
# Good: Context manager
with open('file.txt') as f:
data = f.read()
# Verbose
first = items[0]
second = items[1]
rest = items[2:]
# Pythonic
first, second, *rest = items
# Index tracking manually
i = 0
for item in items:
print(f"{i}: {item}")
i += 1
# Use enumerate
for i, item in enumerate(items):
print(f"{i}: {item}")
# Bug: Blocking call in async function
async def fetch_data():
response = requests.get(url) # Blocks the event loop!
return response.json()
# Fixed: Use async library
async def fetch_data():
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()
# Bug: Coroutine never awaited
async def process():
fetch_data() # Returns coroutine, doesn't execute!
# Fixed
async def process():
await fetch_data()
# Sequential (slow)
async def fetch_all(urls):
results = []
for url in urls:
results.append(await fetch(url))
return results
# Concurrent (fast)
async def fetch_all(urls):
return await asyncio.gather(*[fetch(url) for url in urls])
# Slow: String concatenation in loop
result = ""
for item in items:
result += str(item)
# Fast: Join
result = "".join(str(item) for item in items)
# Memory heavy: Creates full list
def get_values(items):
return [expensive_compute(item) for item in items]
# Memory efficient: Generator
def get_values(items):
return (expensive_compute(item) for item in items)
# Slow: O(n) lookup
if item in large_list:
...
# Fast: O(1) lookup
large_set = set(large_list)
if item in large_set:
...
## Python Review: [File Name]
### Type Safety
- [ ] Type hints complete
- [ ] Types are accurate
- [ ] Optional types handled
### Python Issues
- **Line X**: [Issue description]
```python
# Current
problematic_code()
# Suggested
better_code()
development
Manage VSCode/Cursor configuration in this dotfiles repository. Use when working with settings.json, keybindings.json, or tasks.json files, or when asked about VSCode/Cursor configuration structure.
tools
Design user interfaces and experiences for web applications without requiring design tools. Use for wireframing in text/ASCII, defining user flows, creating component hierarchies, establishing design systems, planning responsive layouts, and making accessibility decisions.
development
Testing specialist focused on comprehensive test coverage for Python applications. Use for pytest patterns, unit/integration/E2E testing, fixtures, mocking, property-based testing with Hypothesis, and factory patterns.
development
Project management adapted for solo developers working without a team. Use for personal project planning, time-boxing work sessions, managing scope creep alone, maintaining momentum on side projects, tracking progress without overhead, making decisions without external input, and staying accountable to yourself.