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

parsing dataclasses with nested Tuples issues #757

Closed
4 tasks
joamatab opened this issue Jun 21, 2021 · 1 comment
Closed
4 tasks

parsing dataclasses with nested Tuples issues #757

joamatab opened this issue Jun 21, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@joamatab
Copy link

Describe the bug
parsing dataclasses with Tuple[Tuple[int, int],...] raises validation errors in 2.0.6 and very strange traceback in 2.1.0

To Reproduce

This will give you an error.

from typing import Tuple, Any
import dataclasses
import pydantic
from omegaconf import OmegaConf


@pydantic.dataclasses.dataclass
class Person:
    favorite_dates: Tuple[Tuple[int,int], ...] = ((11, 1999), (1, 1995))


@pydantic.dataclasses.dataclass
class SimpleTypes:
    num: int = 10
    pi: float = 3.1415
    is_awesome: bool = True
    description: str = "text"
    person: Person = Person()
        
        
OmegaConf.structured(SimpleTypes)

in omegaconf==2.0.6 the error makes sense

ValidationError: Unsupported value type : typing.Tuple[int, int]
	full_key: 
	reference_type=None
	object_type=None

in omegaconf=2.1.0 the error does not make any sense :)

the fix is a bit hacky. I need to define the field as Any

from typing import Tuple, Any
import dataclasses
import pydantic
from omegaconf import OmegaConf


@pydantic.dataclasses.dataclass
class Person:
    favorite_dates: Tuple[Any, ...] = ((11, 1999), (1, 1995))


@pydantic.dataclasses.dataclass
class SimpleTypes:
    num: int = 10
    pi: float = 3.1415
    is_awesome: bool = True
    description: str = "text"
    person: Person = Person()
        
        
OmegaConf.structured(SimpleTypes)

Expected behavior

The code above it should just work

Additional context

  • OmegaConf version: 2.0.6 and 2.1.0
  • Python version: 3.9
  • Operating system: Linux
  • Please provide a minimal repro
@joamatab joamatab added the bug Something isn't working label Jun 21, 2021
@Jasha10
Copy link
Collaborator

Jasha10 commented Jun 21, 2021

Hi,
Thanks for reporting.

in omegaconf=2.1.0 the error does not make any sense :)

The AssertionError in 2.1 is planned to be replaced with a more helpful ValidationError in PR #749.

FYI Tuple support in OmegaConf is currently limited (and undocumented!)
This is an area that is planned for future improvement (reference issue: #392)

Also, nesting container types (e.g. dict-of-dict or list-of-list or dict-of-tuple-of-list) is not yet supported (reference issue: #427).

I'm closing this in favor of the above mentioned issues.

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

No branches or pull requests

2 participants