AxFoundation/strax

Option type is never inferred from default value

Closed this issue · 0 comments

The Option class init overrides the type parameter before it checks whether its OMITTED, resulting in the code that inferrs the type from the default value never to run
the offending line

        type = builtins.type # this overrides the type parameter
        if sum([self.default is not OMITTED,
                self.default_factory is not OMITTED,
                self.default_by_run is not OMITTED]) > 1:
            raise RuntimeError(f"Tried to specify more than one default "
                               f"for option {self.name}.")

        if type is OMITTED and default is not OMITTED: # will never evaluate to True since type is now set to builtins.type
            self.type = type(default)

Expected behavior
type is expected to be inferred from the default value when its not OMITTED