Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sopel: move deprecated() to sopel.lifecycle #2232

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Dec 31, 2021

Description

The deprecated() function is used everywhere, whenever we need to deprecate something. Sometimes, that somethings is right where this function is defined: in sopel.tools, causing cyclic import errors.

In an effort to reduce cyclic import errors, and to organize the code a bit better (mostly by removing everything from sopel/tools/__init__.py), this function is moved to its own sopel's submodule: sopel.lifecycle.

Documentation has been updated accordingly, and every part of Sopel that used sopel.tools.deprecated is now using sopel.lifecycle.deprecated.

In order to prevent yet another cyclic import error, deprecated no longer uses sopel.tools.get_logger to get the logger for an external plugins (that isn't using the namespace), but tries to mimic its behavior for namespace plugins only.

Edit: After discussion, I moved from sopel.deprecated to sopel.lifecycle. This module can be used, in the future to manage more version & lifecycle related things. But for now, I'd rather see this merged than trying to do too much and be frustrated because I've other things in mind that are blocked by this change.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

@Exirel Exirel added this to the 8.0.0 milestone Dec 31, 2021
@Exirel Exirel requested a review from dgw December 31, 2021 20:24
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had another thought since we talked about this, regarding the new module name. What if we called it instead sopel.lifecycle?

At the very least, that makes more sense as a title for the doc page, and it means we could have other API lifecycle stuff in there later. Fancy a decorator for alerting users to planned function signature changes, for example? (That's a quick idea, so don't judge it too hard. 😝)

If you don't like this idea, see line notes for how to improve the docs for how things are in the PR at present.

sopel/deprecated.py Outdated Show resolved Hide resolved
sopel/deprecated.py Outdated Show resolved Hide resolved
docs/source/deprecated.rst Outdated Show resolved Hide resolved
docs/source/deprecated.rst Outdated Show resolved Hide resolved
sopel/tools/__init__.py Outdated Show resolved Hide resolved
@dgw
Copy link
Member

dgw commented Jan 22, 2022

I'm still looking for a general reaction to calling this module sopel.lifecycle or something else like that.

@Exirel
Copy link
Contributor Author

Exirel commented Jan 22, 2022

Hm. Lifecycle could be interesting if we want to add subclass of Warning to be used with Python's warning system, subclasses that could be turned into exception via en env var if we wanted to (like when running test to see what must disappear).

Well, I guess it's time for me to think about that a bit more.

@Exirel Exirel force-pushed the sopel-deprecated-deprecated branch from cf2ea28 to b7ec2b6 Compare January 26, 2022 10:52
@Exirel Exirel requested a review from dgw January 26, 2022 12:27
@Exirel
Copy link
Contributor Author

Exirel commented Jan 26, 2022

Rebased & squashed because conflicts, and then I moved to sopel.lifecycle. I don't think I can come up with a better name, and the prospect of managing version and lifecycle related things into that module is very interesting. So let's go!

@Exirel Exirel changed the title sopel: move deprecated() to sopel.deprecated sopel: move deprecated() to sopel.lifecycle Feb 9, 2022
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it feel like I didn't even look at the code before? Maybe you changed some of this stuff in the rename from sopel.deprecated to sopel.lifecycle, idk.

Also note, you'll want to either squash the second "renale" commit or fix that spelling error. 😸

docs/source/lifecycle.rst Outdated Show resolved Hide resolved
sopel/lifecycle.py Outdated Show resolved Hide resolved
sopel/lifecycle.py Show resolved Hide resolved
sopel/lifecycle.py Outdated Show resolved Hide resolved
sopel/lifecycle.py Outdated Show resolved Hide resolved
sopel/lifecycle.py Outdated Show resolved Hide resolved
sopel/lifecycle.py Outdated Show resolved Hide resolved
@Exirel
Copy link
Contributor Author

Exirel commented Feb 17, 2022

Yup yup applied & fixed. No rebase nor squash yet, of course.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time to squash. Really wish there was a "squash" emoji; either the food or the sport would do.

The `deprecated()` function is used everywhere, whenever we need to
deprecate something. Sometimes, that somethings is right where this
function is defined: in `sopel.tools`, causing cyclic import errors.

In an effort to reduce cyclic import errors, and to organize the code a
bit better (mostly by removing everything from
`sopel/tools/__init__.py`), this function is moved to its own sopel's
submodule: `sopel.deprecated`.

Documentation has been updated accordingly, and every part of Sopel that
used `sopel.tools.deprecated` is now using
`sopel.deprecated.deprecated`.

In order to prevent yet another cyclic import error, `deprecated` no
longer uses `sopel.tools.get_logger` to get the logger for an external
plugins (that isn't using the namespace), but tries to mimic its
behavior for namespace plugins only.

Co-authored-by: dgw <dgw@technobabbl.es>
@Exirel Exirel mentioned this pull request Feb 18, 2022
4 tasks
@dgw dgw merged commit 2e25645 into sopel-irc:master Feb 23, 2022
@Exirel Exirel deleted the sopel-deprecated-deprecated branch February 23, 2022 10:18
@Exirel Exirel linked an issue Jan 13, 2023 that may be closed by this pull request
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.

tools: move deprecated function to prevent circular import
2 participants