-
Notifications
You must be signed in to change notification settings - Fork 1.4k
_abc, _typing and update typing,test_types from 3.14.2 #6797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR updates binary operator return types from PyObjectRef to PyResult across multiple builtin modules, comprehensively reworks PyUnion to track hashable/unhashable arguments separately, implements Python ABC (Abstract Base Classes) mechanics, and updates related type system exports and error handling. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant make_union as make_union()
participant dedup as dedup_and_flatten_args()
participant PyUnion as PyUnion
Caller->>make_union: args: PyTuple
make_union->>dedup: args: PyTuple
dedup->>dedup: Iterate args, track hashable vs unhashable
dedup->>dedup: Deduplicate using hashable set + equality checks
dedup-->>make_union: DedupResult {args, hashable_args, unhashable_args}
alt Single argument
make_union-->>Caller: Return single arg unwrapped
else Multiple arguments
make_union->>PyUnion: from_dedup_result(DedupResult)
PyUnion->>PyUnion: Store hashable/unhashable tracking
PyUnion-->>make_union: PyUnion instance
make_union-->>Caller: PyResult<PyUnion>
end
sequenceDiagram
participant Code as Client Code
participant ABCMethods as ABC Methods
participant Cache as Cache/Registry
participant Counter as Invalidation Counter
Code->>ABCMethods: _abc_subclasscheck(cls, subclass)
ABCMethods->>Cache: Check positive cache
alt Found in cache
Cache-->>ABCMethods: Cached result
else Cache miss
ABCMethods->>Cache: Check negative cache version
alt Version mismatch
ABCMethods->>Counter: Increment invalidation counter
ABCMethods->>Cache: Clear negative cache
end
ABCMethods->>ABCMethods: Check direct subclass/__subclasscheck__
ABCMethods->>Cache: Check registry (recursive)
Cache-->>ABCMethods: Result
ABCMethods->>Cache: Update appropriate cache
end
ABCMethods-->>Code: bool result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin abc |
6df2b89 to
e8077f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/vm/src/builtins/union.rs`:
- Around line 248-332: The dedup_and_flatten_args function currently treats any
error from arg.hash(vm) as "unhashable", masking real exceptions; change the
Err(_) arm to capture the exception (Err(e)) and propagate it unless it's a
TypeError, in which case proceed with unhashable handling. Concretely, in
dedup_and_flatten_args replace the match on arg.hash(vm) so that if Err(e) you
check the exception type (compare against vm.ctx.exceptions.type_error or use
vm.is_instance) and return Err(e) for non-TypeError, otherwise handle as now by
doing equality comparisons and adding to unhashable_list.
🧹 Nitpick comments (2)
crates/vm/src/stdlib/_abc.rs (1)
341-350: Avoid calling into the VM while holdingAbcDatalocks.Drop the lock guard before invoking
set.clear()to reduce reentrancy/deadlock risk; apply the same pattern in_reset_registryand_reset_caches.♻️ Suggested refactor pattern (apply similarly in reset helpers)
- let negative_cache = impl_data.negative_cache.read(); - if let Some(ref set) = *negative_cache { - vm.call_method(set.as_ref(), "clear", ())?; - } - drop(negative_cache); + let negative_cache = impl_data.negative_cache.read(); + let set = negative_cache.as_ref().cloned(); + drop(negative_cache); + if let Some(set) = set { + vm.call_method(set.as_ref(), "clear", ())?; + } impl_data.set_cache_version(invalidation_counter);Also applies to: 453-477
crates/vm/src/builtins/union.rs (1)
389-441: Optional: fast equality path when all args are hashable.If both unions have
unhashable_args == None, consider comparinghashable_args(frozensets) directly to avoid the O(n²) nested loops.
The last commit is generated by #6796
python3 scripts/update_lib quick typingSummary by CodeRabbit
New Features
__name__,__qualname__,__origin__,__parameters__,__args__Improvements
✏️ Tip: You can customize this high-level summary in your review settings.