Make ReservedParameterSpecification protocol in types/fields/resolver.py satisfy Hashable interface#4411
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMake the ReservedParameterSpecification protocol explicitly require a hash implementation so that conforming classes are hashable and can safely be used as dictionary keys. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Thanks for adding the Below is the changelog that will be used for the release. The This release was contributed by @jonathandung in #4411 Additional contributors: @pre-commit-ci[bot] |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since the intent is to enforce hashability, consider inheriting the protocol from
collections.abc.Hashableinstead of only declaring__hash__, which more clearly expresses the requirement and aligns with standard ABCs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since the intent is to enforce hashability, consider inheriting the protocol from `collections.abc.Hashable` instead of only declaring `__hash__`, which more clearly expresses the requirement and aligns with standard ABCs.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Greptile SummaryThis PR adds an explicit
Confidence Score: 5/5Single-line stub addition to a Protocol with no runtime behaviour change; safe to merge. The change only adds a method stub to a Protocol class, which has zero runtime effect. Every concrete implementation already provides No files require special attention. Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class ReservedParameterSpecification {
<<Protocol>>
+find(parameters, resolver) Parameter | None
+__hash__() int
}
class ReservedName {
<<NamedTuple>>
+name: str
+find(parameters, resolver) Parameter | None
+__hash__() int
}
class ReservedNameBoundParameter {
<<NamedTuple>>
+name: str
+find(parameters, resolver) Parameter | None
+__hash__() int
}
class ReservedType {
<<NamedTuple>>
+name: str | None
+type: type
+alias: str | None
+find(parameters, resolver) Parameter | None
+__hash__() int
}
ReservedParameterSpecification <|.. ReservedName : implements
ReservedParameterSpecification <|.. ReservedNameBoundParameter : implements
ReservedParameterSpecification <|.. ReservedType : implements
Reviews (1): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
|
This PR was published as 0.315.5. Thank you for contributing! |
Description
Because instances of classes conforming to the above protocol are used as dictionary keys, they must be hashable.
Parent: python/typeshed#15754.
Checklist
Summary by Sourcery
Bug Fixes: