| name | code-review | ||
|---|---|---|---|
| description | Full code review — SDK patterns, naming, test coverage, code smells, and security. Reads code-smell.md and code-security.md inline. | ||
| paths |
|
You are a senior engineer performing a thorough code review on the Skyflow Python SDK.
Use $ARGUMENTS to determine scope:
full review— scan all files underskyflow/recursively (excludeskyflow/generated/)- A file or directory path — review only that path
- Empty / default — review files changed on current branch vs
main:git diff main...HEAD --name-only | grep '\.py$' | grep -v 'generated'
Skip entirely: skyflow/generated/ — Fern-generated REST client, read-only.
- Request classes are plain data holders — all validation happens in
validate_*_request()insideskyflow/utils/validations/_validations.py, not in__init__. Flag if validation logic is duplicated outside_validations.py. - Response objects are plain dataclasses with an
errorsfield that isNone(not absent) when no errors occurred. - All optional fields must be annotated
Optional[T] = None— never bare= Nonewithout a type annotation. - No separate
*Optionsclasses exist — options are fields on the request object itself.
- All public controller methods must wrap API calls in
try/except Exceptionthat callshandle_exception(e, logger)or raisesSkyflowError SkyflowErrormust be raised with an error code fromSkyflowMessages.ErrorCodes- No bare
except:— always catch a specific type (except Exception:) - No
print()orlogging.xxx()directly — uselog_info()andlog_error_log() - Every validator must call
log_error_log(SkyflowMessages.ErrorLogs.xxx.value)before raisingSkyflowError
| Identifier | Style | Example |
|---|---|---|
| Variable / parameter / method | snake_case |
vault_id, get_records |
| Constant / module-level value | UPPER_SNAKE_CASE |
SKY_META_DATA_HEADER |
| Class / Exception / Enum | PascalCase |
InsertRequest, SkyflowError |
| Private method / attribute | _snake_case |
_validate_ctx |
| Source file | snake_case.py |
_file_upload_request.py |
- Acronyms are all-lowercase in snake_case:
skyflow_idnotskyflow_ID,token_urinottoken_URI - Deprecated methods must use
@deprecatedfromtyping_extensions(compile-time IDE warning) plus awarnings.warn(DeprecationWarning, stacklevel=2)call at runtime
- All response objects must use
snake_casefield names (skyflow_id, notskyflowId) errorsmust be present on every response class, defaulting toNone
- Every public method must have at least one positive and one negative test
- Tests must use
assertEqual/assertIsNone/assertRaises— not just bareassert - No mocking of the class under test
- Use
unittest.mock.patch/MagicMockfor external dependencies (HTTP, file I/O)
- No magic strings for API field names — use
CredentialField,OptionField, orSkyflowMessagesconstants - No duplicate validation logic across request classes — belongs in
_validations.py - No
# noqawithout a comment explaining why warnings.warn(DeprecationWarning, stacklevel=2)must be used for deprecation — neverprint()to stderr
Code smells are structural signals — report at Smell severity.
- Long method — any method over 50 lines. Candidate for decomposition.
- Large parameter list — more than 5 parameters. Consider a request object.
- Business logic in Request/Response classes — these are data holders. Flag any conditional logic beyond simple attribute assignment.
- Validation outside
_validations.py— anyif x is None: raise SkyflowError(...)outsideskyflow/utils/validations/is misplaced.
- Deep nesting — more than 3 levels of
if/for/try. Extract inner blocks to named helpers or use early returns. - Long if-else chains — more than 4 branches. Consider a dispatch dict.
- Magic numbers — literal integers used in comparisons or sizes without a named constant.
- Mutable default arguments —
def f(x=[])ordef f(x={}). Replace withNoneand initialise in the body.
- Unused private methods or unused imports — run
ruff check --select=F401. - Commented-out code — remove or add a
# TODO: [ticket]reference.
Group findings by file:
### skyflow/path/to/file.py
| Severity | Line | Finding |
|------------|------|------------------------------------------------------------|
| Critical | 42 | SkyflowError swallowed in except block |
| Bug | 87 | skyflow_id not set on response object |
| Quality | 103 | Magic string "records" — use OptionField constant |
| Smell | 210 | Method is 65 lines — candidate for decomposition |
Severities:
| Level | Meaning |
|---|---|
| Critical | Data loss, silent failure, security risk — must fix before merge |
| Bug | Wrong behaviour, incorrect output — must fix before merge |
| Edge Case | Unhandled input that will cause runtime failure — fix before merge |
| Quality | Maintainability issue, naming violation, missing pattern — fix before merge |
| Smell | Structural signal, technical debt — flag and track |
End with:
- A tech-debt summary table grouped by category (Error handling / Naming / Smells / Tests)
- A verdict:
APPROVE/APPROVE WITH FIXES/REQUEST CHANGES