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

Can not pass sample codes from README.md. #57

Closed
ChiahungTai opened this issue Oct 22, 2022 · 4 comments
Closed

Can not pass sample codes from README.md. #57

ChiahungTai opened this issue Oct 22, 2022 · 4 comments

Comments

@ChiahungTai
Copy link

I can not pass below sample codes from README.md.

@dataclass
class Example:
    hello: string
    world: string

os.environ['DC_WORLD'] = 'monde'

print(
    dataconf
    .multi
    .url('https://raw.githubusercontent.com/zifeo/dataconf/master/confs/simple.hocon')
    .env('DC')
    .on(Example)
)
# Example(hello='bonjour',world='monde')

First error is about below line.
hello: string =>no string

After replace string to str, I got below error msgs.

"
dataconf
../../../opt/anaconda3/envs/test/lib/python3.8/site-packages/dataconf/main.py:89: in on
conf = ConfigTree.merge_configs(conf, nxt)
../../../opt/anaconda3/envs/test/lib/python3.8/site-packages/pyhocon/config_tree.py:61: in merge_configs
a[key] = value
E TypeError: list indices must be integers or slices, not str
"

@zifeo
Copy link
Owner

zifeo commented Oct 22, 2022

@ChiahungTai Thanks for the report. The readme is indeed outdated:

In the meanwhile, the following should work:

@dataclass
class Example:
    hello: str
    world: str
    foo: List[str]

os.environ['DC_WORLD'] = 'monde'

print(
    dataconf
    .multi
    .url('https://raw.githubusercontent.com/zifeo/dataconf/main/confs/simple.json')
    .env('DC')
    .on(Example)
)

@zifeo zifeo closed this as completed in d3a82bc Oct 22, 2022
@ChiahungTai
Copy link
Author

Thanks for the quick response. :)

@zifeo
Copy link
Owner

zifeo commented Oct 22, 2022

@ChiahungTai 2.1.2 should now raised an error if the source is missing.

@ChiahungTai
Copy link
Author

@ChiahungTai 2.1.2 should now raised an error if the source is missing.

I have upgraded the dataconf to 2.1.2.
It works! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants