Skip to content
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

Option type is never inferred from default value #568

Closed
jmosbacher opened this issue Oct 31, 2021 · 0 comments · Fixed by #569
Closed

Option type is never inferred from default value #568

jmosbacher opened this issue Oct 31, 2021 · 0 comments · Fixed by #569
Labels
bug Something isn't working

Comments

@jmosbacher
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant