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

config_from_{json, yaml, ini, toml, dotenv} should accept a pathlib.Path as a data parameter. #96

Closed
publicmatt opened this issue Apr 5, 2024 · 0 comments

Comments

@publicmatt
Copy link
Contributor

Right now it looks like most of the methods to define a file path take a Union[str, TextIO] type. It would be nice if it were possible to pass a pathlib.Path type as well:

from pathlib import Path
root = Path(__file__).parent
cfg = config_from_dotenv(root / '.env', read_from_file=true)

Right now, when I try to do so, I get the following error:

  File "/path/to/.venv/lib/python3.11/site-packages/config/__init__.py", line 579, in _reload
    data = data.read()
           ^^^^^^^^^

There might have to be some introspection of the data object, or a conversion of the str to a Path.

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