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

Consider deprecating assignment of strings to non-string nodes like IntegerNode / FloatNode #459

Open
odelalleau opened this issue Dec 15, 2020 · 1 comment

Comments

@odelalleau
Copy link
Collaborator

odelalleau commented Dec 15, 2020

Is your feature request related to a problem? Please describe.

Currently OmegaConf accepts the following string assignment:

@dataclass
class Foo:
  x: int = 10

cfg: Foo = OmegaConf.structured(Foo)
cfg.x = "20"  # OmegaConf happily converts from string to int, though mypy would complain

Describe the solution you'd like

Deprecate this functionality to increase type safety. More precisely, all assignments that mypy would complain about should raise a deprecation warning (and, later, an error)

Additional context

This issue was written following the discussion here: https://github.com/omry/omegaconf/pull/445/files#r541981251

@omry
Copy link
Owner

omry commented Dec 15, 2020

Note that this behavior is well documented in 2.0 and the docs will have to reflect this change.
This extends to boolean as well.
Note that merge should still support it.

@omry omry changed the title Deprecate assignment of strings to non-string nodes like IntegerNode / FloatNode Consider deprecating assignment of strings to non-string nodes like IntegerNode / FloatNode Dec 26, 2020
@omry omry mentioned this issue May 10, 2021
@omry omry added this to the OmegaConf 2.2 milestone Jun 4, 2021
@pixelb pixelb modified the milestones: OmegaConf 2.2, OmegaConf 2.3 May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants