-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
config.types, test: add BooleanAttribute
setting type
#2044
Conversation
This pull request introduces 1 alert when merging 6fb5c0a into 4639e00 - view on LGTM.com new alerts:
|
Simply could not think of a better approach to emitting deprecation warnings for |
Indeed. If you want to reduce the duplicated code, you can:
The content of said function would be something like: @deprecate(...)
def _get_deprecated_boolean_handlers(parser=None, serializer=None):
# ... logic from that if bool block
return the_boolean_parser, the_boolean_serializer Problem solved. |
Not really. I mean technically, it deduplicates the code, but the warning printed is this:
That doesn't tell the user or plugin developer where the outdated usage lies. If |
We can always add the field's name in the deprecation message, that should help a bit. |
I'm not at all sure how you'd do that from a decorator on a helper function called from the object constructor, but if I can learn something from you again, I'm all eyes. |
I'd do that within the constructor:
Not perfect, but it works and it's temporary. |
I guess defining stuff inside other defs is not unheard of in Sopel's code, e.g. the old signal handlers. But even that approach would benefit from the PR I'm about to open against And don't worry, I did see your muttering on IRC about using |
Yup, and if that PR can be merged first, go for it. I think it would be the better option here. |
Pushed using the new kwarg to Might want to clean up history later anyway, tbf. |
This pull request introduces 1 alert when merging bed0471 into 96c55af - view on LGTM.com new alerts:
|
Was going to move the helper functions used in `ValidatedAttribute` when `parse == bool`, but it would've required some ridiculous polymorphism. Maybe we need to add tests that cover the `default` parameter to some or all of these setting types? I'll chew on that.
This will fire only once, when the setting object is initialized.
Exi provided the inspiration, and I made it work after adding a new feature to Sopel's deprecation decorator. 🙃 Co-Authored-By: Exirel <florian.strzelecki@gmail.com>
2a0298f
to
220b3af
Compare
I cleaned up the history. @Exirel presumably will be the one to review this, as it uses his suggested approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
Was going to move the helper functions used in
ValidatedAttribute
whenparse == bool
, but it would've required some ridiculous polymorphism. Better to just leave the old stuff—which will also make it easier to mark as deprecated.Maybe we need to add tests that cover the
default
parameter to some or all of these setting types? I'll chew on that.When complete, this will implement and close #2019.
Checklist
make qa
(runsmake quality
andmake test
)