Conversation
Add type-safe query methods (select, ask, construct, describe) with specific return types instead of the generic union type from query(). Each method returns a specific type for better IDE support and type safety. New features: - select() returns QuerySolutions - ask() returns bool - construct() returns QueryTriples - describe() returns QueryTriples - Variable bindings support via bindings parameter - Optional strict mode to validate query type before execution New types: - QueryTypeMismatchError exception for strict mode validation - Term type alias for IRI | BlankNode | Literal - QueryBindings type alias for dict[str, Term] Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- `pyproject.toml` - contains dev dependency additions (pytest, pytest-asyncio) that were needed for testing - `requirements-dev.lock` and `requirements.lock` - lock files generated by rye These are development setup changes, not part of the feature implementation. Would you like me to commit these as well, or should they be discarded?
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 8e55dc4 in 11 seconds. Click for details.
- Reviewed
938lines of code in10files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_Utreag8ycovEHIql
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
Add exhaustive test coverage for strict mode query type validation: - TestStrictModeMismatch: 13 tests covering all query type mismatches (SELECT/ASK/CONSTRUCT/DESCRIBE cross-combinations) - TestStrictModeBlocksUpdateQueries: 12 tests ensuring INSERT/DELETE/ CLEAR/DROP queries are blocked on read methods when strict=True These tests verify that strict mode properly validates query types before sending requests to the server, preventing accidental use of UPDATE queries on read endpoints. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed e6585f8 in 26 seconds. Click for details.
- Reviewed
279lines of code in1files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_c4wDg3mEgOxBCYwK
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Summary
Adds type-safe, fine-grained SPARQL query methods (
select(),ask(),construct(),describe()) to the repository API. Each method returns a specific type instead of the previous generic union type, improving IDE support and type safety.Why
The existing
query()method returns a union type (QuerySolutions | QueryBoolean | QueryTriples), which:This change provides a more ergonomic API that matches developer expectations and the underlying SPARQL specification.
Key Changes
New Query Methods
select(query, infer, bindings, strict)→QuerySolutionsask(query, infer, bindings, strict)→boolconstruct(query, infer, bindings, strict)→QueryTriplesdescribe(query, infer, bindings, strict)→QueryTriplesNew Features
bindingsparameter for parameterized queries (maps variable names to RDF terms)strict=Truevalidates query type before execution, raisingQueryTypeMismatchErrorif mismatchedNew Types
QueryTypeMismatchError- Exception for strict mode validation errorsTerm- Type alias forIRI | BlankNode | LiteralQueryBindings- Type alias fordict[str, Term]Updated Methods
query()- Addedbindingsparameter (backward compatible)update()- Simplified signature, addedbindingsparameterFiles Changed
rdf4j_python/_driver/_async_repository.py- Core implementation (+302 lines)rdf4j_python/exception/repo_exception.py- New exception typerdf4j_python/model/term.py- New type aliasestests/test_fine_grained_queries.py- Comprehensive test suiteImpact
query()method signature is backward compatiblepytestandpytest-asynciofor testing🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com
Important
Adds type-safe SPARQL query methods to
AsyncRdf4JRepositorywith strict mode validation and comprehensive tests.select(),ask(),construct(),describe()methods toAsyncRdf4JRepositoryfor type-safe SPARQL queries.select()returnsQuerySolutions,ask()returnsbool,construct()anddescribe()returnQueryTriples.strictmode to validate query type before execution, raisingQueryTypeMismatchErrorif mismatched.QueryTypeMismatchErrorinrepo_exception.pyfor strict mode validation errors.TermandQueryBindingstype aliases interm.py.query()andupdate()methods in_async_repository.pyto supportbindingsparameter.pytestandpytest-asyncioas dev dependencies inpyproject.toml.test_fine_grained_queries.py.This description was created by
for e6585f8. You can customize this summary. It will automatically update as commits are pushed.