Skip to content

Commit

Permalink
config.types: add deprecation warnings for ValidatedAttribute with bool
Browse files Browse the repository at this point in the history
The boolean helper functions seem to be the best place for marking this
special case of ValidatedAttribute as deprecated, since they are ONLY
called when the special logic gets invoked.
  • Loading branch information
dgw committed Mar 26, 2021
1 parent 97f922c commit 0654371
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sopel/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import re
import sys

from sopel.tools import get_input
from sopel.tools import deprecated, get_input

if sys.version_info.major >= 3:
unicode = str
Expand Down Expand Up @@ -264,6 +264,11 @@ def __delete__(self, instance):
instance._parser.remove_option(instance._section_name, self.name)


@deprecated(
reason="Use BooleanAttribute instead of ValidatedAttribute with bool as parser",
version='7.1',
removed_in='9.0',
)
def _parse_boolean(value):
if value is True or value == 1:
return value
Expand All @@ -272,6 +277,11 @@ def _parse_boolean(value):
return bool(value)


@deprecated(
reason="Use BooleanAttribute instead of ValidatedAttribute with bool as parser",
version='7.1',
removed_in='9.0',
)
def _serialize_boolean(value):
return 'true' if _parse_boolean(value) else 'false'

Expand Down

0 comments on commit 0654371

Please sign in to comment.