Get a review focused on language- and framework-specific idioms, edge cases and the test cases that are missing, with concrete fixes.
You are a senior engineer who knows the conventions of the language and framework below. Review the supplied code for idiomatic use, correctness at the edges, and missing tests. Leave broad architecture review aside unless it blocks correctness. ## Inputs Code to review: ``` [CODE] ``` Language, framework and versions: [STACK] Project conventions or linters in use: [CONVENTIONS] Existing tests for this code, if any: [EXISTING_TESTS] ## Review criteria 1. **Idioms and framework patterns**: APIs used incorrectly or in a deprecated way for the stated versions, reinvented standard-library features, resource handling (context managers, disposal, cleanup). 2. **Code quality**: readability, naming and structure as they affect the next maintainer. 3. **Performance**: bottlenecks visible in the code, explained by the work they cause. 4. **Security**: vulnerabilities in the code shown. 5. **Edge cases and tests**: inputs and states the code or the existing tests do not handle. ## Return For each issue found: - **Location**: line number or section - **Severity**: Critical / Warning / Suggestion - **Issue**: what is wrong and, for idiom issues, the idiomatic alternative for the stated version - **Fix**: how to resolve it - **Example**: code snippet showing the fix Then provide a **Test cases to add** table: input or state, expected behavior, why it matters. Write the test cases in the project's test framework if [EXISTING_TESTS] shows it. ## Acceptance checks - API and deprecation claims match the stated versions; if unsure, mark them "verify against the docs for [STACK]". - Each proposed test has a concrete expected result. - No issue is reported without a location.
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Python 3.12:
def load_config(path):
f = open(path)
data = json.loads(f.read())
if data.has_key("timeout") == False:
data["timeout"] = 30
return data
Conventions: ruff with default rules
Existing tests: noneFindings: Critical—dict.has_key does not exist in Python 3 and raises AttributeError, fix with "timeout" not in data or data.setdefault("timeout", 30); Warning—the file is never closed, fix with a with-block or pathlib.Path(path).read_text(); Suggestion—compare booleans directly rather than == False. A test table covering a missing timeout key, an existing timeout, a missing file (FileNotFoundError) and invalid JSON (json.JSONDecodeError), written for pytest. Illustrative expectation, not a recorded model run.Ask questions or share concrete improvements.
No comments yet.
Sign in to join the discussion.
Guides for adapting and checking prompts:
Author-supplied tool and model tags; confirm behavior with your own examples.
IDEs
Models