-
Notifications
You must be signed in to change notification settings - Fork 990
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing broken deprecation namings (#3174)
Fixes #3170. The deprecated decorator should not be used in a way it was directly used. The pattern was: ``` old_function = deprecated( deadline='v0.9', fix='Use cirq.new_func instead.')( cirq.new_func) ``` The main problem is that we pass in the _new_ function into the deprecated decorator...now it does return a new function instance that is a decorated one and hence the old function gets a good wrapper around it. However, the name calculation in case `name` arg is not defined cannot determine what the name of `old_function` is. There are two ways to fix this AFAICT (unless I'm missing some python magic that can tell what the name of the variable is that is calling the current function - which I found to be not possible): 1.) set `name` and duplicate the variable (function) name ``` old_function = deprecated( deadline='v0.9', fix='Use cirq.new_func instead.', name = 'old_function')( cirq.new_func) ``` 2.) use the decorator on a proper def ``` @deprecated( deadline='v0.9', fix='Use cirq.new_func instead.', name = 'old_function') def old_function(*args,**kwargs): return cirq.new_func(*args,**kwargs) ``` I chose 2 in my solution, a bit more verbose but there is no duplication at least.
- Loading branch information
Showing
6 changed files
with
72 additions
and
35 deletions.
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
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
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
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
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
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