Conversation
lib/iris/_deprecation_helpers.py
Outdated
| # Set this as the init for the wrapper class. | ||
| initfn.func_name = '__init__' | ||
| # Also copy the original docstring. | ||
| initfn.__doc__ = parent_class.__init__.__doc__ |
There was a problem hiding this comment.
Probably cleaner to do this with functools.wraps
There was a problem hiding this comment.
I did wonder about that, but I couldn't quite work out how to make it go.
I'll take another look.
There was a problem hiding this comment.
Perhaps...
@wraps(parent_class.__init__)
def initfn(self, *args, **kwargs):
print(...)There was a problem hiding this comment.
... actually, I've got a problem here...
The documentation is not getting the constructor signatures right for any of my classes wrapped with this 'ClassDeprecationWrapper' : They all appear to be class(*args, **kwargs).
This is not helpful + not what I intended.
I see that the docs of the existing master already has this problem, where I had deprecated iris.fileformats.ff.
I think it relates to : http://stackoverflow.com/a/17705456
Does anyone know how to fix this properly without having to define an independent matching __init__ for each wrapper class ?
There was a problem hiding this comment.
how to fix this properly
Use Python 3.4 😉 It's more complicated for Python 2.
|
Looks like excellent progress - thanks @pp-mo 😄 Good idea to keep using the old code internally so we don't have to transition our internal usage (with the likely impact on test results) in the same PR. 👍 |
|
Thanks @rhattersley |
|
I do hope I've fixed it now... P.S.
Just to be clear, the point at issue here is not any oddness of Python, or metaclasses, but an oddness of Sphinx. I can fix "help(x)", but not the Sphinx output, apparently because it defines an overall "class constructor signature" in a slightly surprising way. |
Thanks for clarifying. 👍 Given the deprecated classes are transient code and you've already boiled it down to a simple, repeatable pattern I'm OK with leaving your solution as it stands. There's no need to burn extra time on a "fancy" solution that works with every permutation of Python 2/3 and Sphinx. |
|
@pp-mo - I'm 👍 for the content. With hindsight, can we easily squash this down to a small number (but more than one) of coherent commits? If not, I think I'd rather merge it as it stands than squash down to a single commit. |
Nudge...? |
Thanks @rhattersley. Coming... |
… equivalence to newer methods.
…analysis.interpolate.
1a7fa2f to
bd0e11e
Compare
Now done that, or something like it. |
|
Thanks @pp-mo 👍 😄 |
|
Just following this up now (I know, how many months ago), but I'm not sure it is clear what functionality has replaced Thanks! |
There's a redirect in the docstring for the deprecated routine. It says ...
But I just realised I messed up the docs build for this in the way I wrapped these routines, so we are no longer building docs for them (!oops) |
|
P.S.
Does this actually address the need you mention, or am I maybe missing something about the usage with multiple sample-point requirements ? E.G. Here's my equivalent code for the docstring example.... If that's not too horrible ? |
|
Thanks for your example @pp-mo. Definitely less clear than it was, but I can live with it 😄 |
Deprecation of
cube.regriddedand the whole ofiris.analysis.interpolatemodule.We basically want all of these older methods updated to the new scheme-based "cube.regrid" and "cube.interpolate".
It's a bit noisy, partly unavoidable due to renames.
It should be clearer from the individual commits.