Repository navigation
Conversation
|
This PR derives from #5171, where the discussion lead to a decorator to handle renamed keyword parameters. I felt that changes were large enough that the decorator part should be its own PR, since it has little to do with the replacement of the NB: naming and wording may want some change. E.g., "renamed" may be better than "replaced". |
The ``replaced_parameter`` decorator allows for the old use of a function or method where a parameter has been deprecated and replaced by one with a different name. The new parameter should otherwise function the same.
|
|
||
| - New decorator: replaced_argument. This can be used for functions | ||
| that have renamed a keyword, but still want to allow for use of | ||
| the older keyword. |
There was a problem hiding this comment.
You need to attach this PR number to the entry. See other entries for example.
I agree, rename sounds better. For replace I think about changing the order rather than the name itself. |
| def test_replaced_parameter(): | ||
| @replaced_parameter('clobber', 'overwrite', since='1.3') | ||
| def test(a, overwrite=False, c=10): | ||
| """A simple test function |
There was a problem hiding this comment.
helper functions for tests generally don't need docstrings if they are just dummies.
There was a problem hiding this comment.
This docstring is to test whether the "..versionchanged" part gets appended properly (see a few lines below). I'll shorten it though.
There was a problem hiding this comment.
Oh, I totally forgot that the versionchanged is only appended if there is already a docstring. Sorry for the noise.
|
@evertrol I also had a commit for the decorator (I was about to make a PR when I realized you already opened one). If you want you can have a look: https://github.com/MSeifert04/astropy/commit/b0d65c6bff58f5a38aaf570cfc7200345b4e24c6 |
|
@MSeifert04 If you like, I'm happy to withdraw this PR in place of yours, since you came up with the decorator in the first place. Otherwise, I'll incorporate parts of your PR into mine; the |
|
@evertrol I know at least one place where I'll don't know if it's easy to make a PR against your branch because they now differ in some aspects. I will take a look later. |
|
@evertrol , @MSeifert04 -- Whichever of you end up with the final PR, you can still credit each other by manually changing the commit author via |
|
@pllim Where do you always get these handy informations? I never heard of manually changing the author of the commit 😮 But wouldn't it completly replace the person doing the commit? I actually don't know what the best way to proceed would be. The decorators behave similar but each has some unique features which would be nice to have in the other one. |
|
@MSeifert04 , I did that in #3094 . If you look at the commits there, you will see some "such-and-such commited with such-and-such" entries. |
It's usually described in git tutorials under "Rewrite history" or similar sections. However you're right, doing what @pllim suggests above completely changes the author, and that's shows up in the Needless to say git and git history are thus not suitable for fair credit sharing for e.g. pair coding or team brainstorming, etc. |
|
@MSeifert04 The |
The
replaced_parameterdecorator allows for the old use of afunction or method where a parameter has been deprecated and replaced
by one with a different name. The new parameter should otherwise
function the same.