deprecating parameters

John Arbash Meinel john at arbash-meinel.com
Mon Jan 16 01:39:47 GMT 2006


Robert Collins wrote:
> So, for symbol versioning in the branch-formats branch I needed to mark
> Branch(..., init=XXX) as deprecated.
> 
> I've used the follow for now:
> 
>     def __init__(self, transport, init=deprecated_nonce,
>                  relax_version_check=False):
> ....
> 
>         if deprecated_passed(init):
>             warn("BzrBranch.__init__(..., init=XXX): The init parameter
> is "
>                  "deprecated. Please use Branch.initialize().",
>                  DeprecationWarning)
> 
> 
> deprecated_nonce is a marker used by deprecated_passed - its assumed
> noone will ever deliberately pass deprecated_none into a routine (and if
> they do, their problem). (Its an object instance, theres no way to
> accidentally do this).
> 
> 
> I took this route because I was not sure how to make a -nice- parameter
> deprecation decorator at this point - but I'm adding a TODO to research
> that later.
> 
> Does this sound reasonable to folk ?
> 
> Rob
> 

What do you consider to be a 'nice' parameter deprecation decorator.
Because couldn't you do something like:

@deprecated_parameter(3, 'init')

And then inside the wrapper, you could check if 'args' is long enough to
contain the deprecated parameter, or if 'kwargs' contains the keyword.

Nicer, probably would be to just do:
@deprecated_parameter('init')

And then have the internal function look at func.fu_code to figure out
what *args parameter it would be, or what **kwargs parameter it would be.

I'm okay with what you did if it is easier.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060115/38886eba/attachment.pgp 


More information about the bazaar mailing list