hi! on pants 2.19, I'm seeing an unexpected behavi...
# general
e
hi! on pants 2.19, I'm seeing an unexpected behavior with a subsystem
BoolOption
Copy code
class MySubsystem(Subsystem):
    test = BoolOption(
        default=None,
        help=softwrap("test"),
        advanced=False,
    )
From the doc string, I expect the default value to be
None
, but I'm seeing
False
instead. From the help output:
Copy code
--[no-]mysubsystem-test
  PANTS_MYSUBSYSTEM_TEST
  test
      default: None
      current value: False
      test
Any insight would be appreciated.
h
What happens if you omit
default=
entirely?
I'm taking the "If you don't provide..." part very literally
e
it throws an exception that default is required
Copy code
Exception message: __new__() missing 1 required keyword-only argument: 'default'
NoneType: None
c
Not that this solves the mystery of the docstring, but you can use
TriBoolField
e
sorry, i'm new to pants, but are the Field types interchangeable with Option types for use in a Subsystem?
c
oh, my bad, you are correct, they are not interchangeable
e
i found a workaround for now. rather than check the value for
None
, i can use the
is_flagged
method to check if a value was supplied.
h
Hmmm, so that documentation is misleading...
e
personally i think it's a bug. the other scalar types behave as expected when default=None.
e.g. StrOption
h
Hmm, can you file an issue? The behavior should be consistent, so I'd tend to agree it's a bug if it isn't
e
sure, will do
w
This feels relevant...
pants.option.parser
I don't recall seeing
UnsetBool
anywhere, but yeah.... I feel like this should be documented 🙂
Annoying that
UnsetBool
breaks typing though. Needs some type love
e
neat