Skip to content

Allow methods calls for structured configs #1237

@winniehell

Description

@winniehell

Describe the bug

When calling methods of classes that are wrapped in structured configs, ConfigAttributeError is raised.

To Reproduce

from omegaconf import OmegaConf
from dataclasses import dataclass

@dataclass
class MyConfig:
    value: int

    def print_formatted_value(self):
        print(f'This is my value: {self.value}')

# prints This is my value: 42
MyConfig(value=42).print_formatted_value()

# raises omegaconf.errors.ConfigAttributeError: Key 'print_formatted_value' not in 'MyConfig'
OmegaConf.structured(MyConfig(value=42)).print_formatted_value()

Expected behavior

Method calls on structured configs are possible.

Additional context

  • OmegaConf version: 2.3.0
  • Python version: doesn't matter
  • Operating system: doesn't matter
  • Please provide a minimal repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions