We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
The doc string for the BoolOption type says:
BoolOption
If you don't provide a default value, this becomes a "tri-bool" where the property will return None if unset by the user.
default
None
This is consistent with the other "scalar" option types, however in practice BoolOption does not adhere to this behavior, while the others do.
Given this example subsystem class:
from pants.option.option_types import BoolOption, StrOption, IntOption, FloatOption from pants.option.subsystem import Subsystem class MySubsystem(Subsystem): name = "My subsystem" options_scope = "my-subsystem" help = "My subsystem" bool_option = BoolOption( help="a boolean", default=None, ) int_option = IntOption( help="an integer", default=None, ) float_option = FloatOption( help="a float", default=None, ) str_option = StrOption( help="a string", default=None, )
We can see in the following help output that the default (and current) value for the BoolOption is False, not None as documented/expected:
False
$ pants --no-pantsd help my-subsystem `my-subsystem` subsystem options -------------------------------- My subsystem Activated by zocdoc.pants Config section: [my-subsystem] --[no-]my-subsystem-bool-option PANTS_MY_SUBSYSTEM_BOOL_OPTION bool_option default: False current value: False a boolean --my-subsystem-int-option=<int> PANTS_MY_SUBSYSTEM_INT_OPTION int_option default: None current value: None an integer --my-subsystem-float-option=<float> PANTS_MY_SUBSYSTEM_FLOAT_OPTION float_option default: None current value: None a float --my-subsystem-str-option=<str> PANTS_MY_SUBSYSTEM_STR_OPTION str_option default: None current value: None a string
Pants version
$ pants --version 2.19.0
OS MacOS on Apple silicon
The text was updated successfully, but these errors were encountered:
Slack discussion: https://pantsbuild.slack.com/archives/C046T6T9U/p1713281183584689
Sorry, something went wrong.
As per my comment in Slack, apparently you need to use UnsetBool
UnsetBool
from pants.option.custom_types import UnsetBool foo = BoolOption( default=UnsetBool, help="bar", )
No branches or pull requests
Describe the bug
The doc string for the
BoolOption
type says:This is consistent with the other "scalar" option types, however in practice
BoolOption
does not adhere to this behavior, while the others do.Given this example subsystem class:
We can see in the following help output that the default (and current) value for the
BoolOption
isFalse
, notNone
as documented/expected:Pants version
OS
MacOS on Apple silicon
The text was updated successfully, but these errors were encountered: