Skip to content

Demo: deprecators - #3346

Closed
hmaarrfk wants to merge 5 commits into
scikit-image:masterfrom
hmaarrfk:deprecators
Closed

hmaarrfk wants to merge 5 commits into
scikit-image:masterfrom
hmaarrfk:deprecators

Conversation

@hmaarrfk

Copy link
Copy Markdown
Member

This is a small demo about how a decorator I wrote could be used to transition to keyword only arguments.

@jni

If i can remember how to compile the docs, I'll try to show how they look in screenshots

But you can read more about the package here
https://deprecation-factory.readthedocs.io/en/latest/index.html
Some advantages of using this would be:

  • The library write the warning message in the docs.
  • The library warns your users telling them how to get rid of the warning too.
  • The library will point the user to their line of code, so that they can make the appropriate modifications.
  • It is even safe to leave the deprecators in place after the threshold version has been reached. The decorator will behave as a no-op and your library will use the updated version of your code. Deprecations should not have to be blockers for your development.

References

#3045 (not exactly related to this particular demo, but the library can deprecate default values)

For reviewers

(Don't remove the checklist below.)

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

@pep8speaks

This comment has been minimized.

@hmaarrfk

Copy link
Copy Markdown
Member Author

image

@jni

jni commented Aug 13, 2018

Copy link
Copy Markdown
Member

I gotta admit, that's pretty gorgeous. =)

@codecov-io

This comment has been minimized.

@soupault

soupault commented Aug 15, 2018 •

Copy link
Copy Markdown
Member

Give me some time, please, I've to check this PR with the Federal Antimonopoly Service. :trollface:
The library look interesting, but, from my perspective, requires more work before we can make it a dependency (if we decide so). Thanks for the demo!

@soupault soupault added this to the 1.0 milestone Aug 15, 2018
@hmaarrfk

Copy link
Copy Markdown
Member Author

Regarding making it a dependency, I would simply version what you want from. I don't think scikit-image can afford to depend on an alpha library....

I can give scikit-image an other license for it so they don't have to drag around my license text.

I just wanted to show that it is possible, to a certain extent, not have to create long todo lists with confusion default parameters when deprecating things.

@hmaarrfk

Copy link
Copy Markdown
Member Author

Finally, one last thing to note is weather or not you want this kind of "magic".

Setting something to None and then calling the deprecated behaviour is pretty understandable, though, cumbersome to maintain.

Those decorators are not understandable. I can maybe improve that with some refactoring, but ultimately, they rely on python introspection which is essentially magic... Me of 6 months ago would have not understood them.

@jni

jni commented Sep 6, 2018

Copy link
Copy Markdown
Member

@hmaarrfk thanks again for this. I want to simplify the upstream code and change some names ("kwonly" sounds pretty wonky to me), but I'm very much leaning in favour of adopting something like this. It would simplify our deprecation procedures.

As to the library name, I humbly suggest wabisabi. From Wikipedia:

In traditional Japanese aesthetics, wabi-sabi (侘寂) is a world view centered on the acceptance of transience and imperfection.

@hmaarrfk

hmaarrfk commented Sep 6, 2018

Copy link
Copy Markdown
Member Author

I'm glad to take some simplifications upstream so long as breaking changes to the tests can be justified.

Also, I'm hoping that performance doesn't get affected too much by such heavy handed use of decorators.

I'm also happy to

  1. Take the simplifications upstream
  2. To give an unrestricted license to skimage for versioning the code (this would allow you to remove the license from the comments)

Preferably in that order in order to retain the ability to relicense wabisabi later on. If versionning is the way you want to move forward (which I recommend), feel free to issue the PR and CC me so that I can formally agree to giving license over to skimage on that PR.

Please open an issue on deprecation-factory for the name change, I'm hoping it won't happen more than once. I won't maintain the old names, hence why I recommend versionning.

@hmaarrfk hmaarrfk closed this Nov 3, 2018
@hmaarrfk
hmaarrfk deleted the deprecators branch November 4, 2018 13:30
@hmaarrfk
hmaarrfk restored the deprecators branch November 4, 2018 13:30
@hmaarrfk
hmaarrfk deleted the deprecators branch November 4, 2018 13:35
@hmaarrfk
hmaarrfk restored the deprecators branch November 4, 2018 13:35
@hmaarrfk

Copy link
Copy Markdown
Member Author

@jni, @alexdesiqueira this is the demo that I was talking about regarding how the decorator can be used to basically make the change "once".

In version 1.0, you are left with "zombie" decorators that would basically do nothing.

https://github.com/hmaarrfk/wabisabi/blob/master/wabisabi/kwonly_change.py#L89

@hmaarrfk hmaarrfk mentioned this pull request Feb 18, 2020
9 tasks
@jarrodmillman jarrodmillman removed this from the 0.21 milestone Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants