-
Notifications
You must be signed in to change notification settings - Fork 161
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
PR: Add type annotations for rope.contrib.generate.create_generate() #641
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8fc5abb
Improve docstring for create_generate
edreamleo 39a26e2
Fully annotate create_generate
edreamleo 9b1fa56
Back out of Literal annotation
edreamleo 7d220ea
Merge branch 'master' into ekr-ropemode-docstring
edreamleo af8f5c0
Merge branch 'master' into ekr-ropemode-docstring
edreamleo d85914b
Fix recent problems w/ annotations. Punt on the return type for now
edreamleo c9929a0
Merge branch 'ekr-ropemode-docstring' of https://github.com/edreamleo…
edreamleo 4242e94
Merge branch 'master' into ekr-ropemode-docstring
lieryan 2fc4bb8
Annotate rope.contrib.generate.create_generate(kind) with Literal
lieryan File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is accurate annotation, but I think this would be promising too much to the caller.
create_generate()
is a factory method for creating refactoring operation; so rather than documenting the exact types that it can return, we should just document what it is able to promise:create_generate()
will return an object that matches the Refactoring interface.rope currently doesn't have a formal interface for Refactoring class, but if it does, it would be an
Protocol
orabc
that looks somewhat like this:callers of
create_generate()
should only depend on it returning a class that matches the Refactoring interface, and they shouldn't rely on the concrete classes.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.
Alternatively, we can annotate
create_generate()
as returning a more specificGenerateRefactoring
Protocol, which can further add a promise thatget_changes()
doesn't take any parameters and that there is also an additionalget_location()
method:this would be a more risky to promise in the API, since if we later change our mind and want to add a parameter to
_Generate.get_changes()
, that would need to be an API breaking change.