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

Support path-like objects #106

Closed
dmwyatt opened this issue Jan 11, 2017 · 2 comments · Fixed by #313
Closed

Support path-like objects #106

dmwyatt opened this issue Jan 11, 2017 · 2 comments · Fixed by #313
Assignees
Labels
enhancement New feature or request

Comments

@dmwyatt
Copy link
Contributor

dmwyatt commented Jan 11, 2017

Python 3.6 finally implements PEP 519. This means we can use pathlib.Path instances in standard library methods that expect a string path. For example we can do

a_path = Path('/home/dmwyatt/some_file.txt')
with open(a_path) as f:
    file_contents = f.read()

At a minimum, I recommend supporting passing path-like objects into read_env. You can check if an object is a path-like object by using isinstance(a_path, os.PathLike). In the case of read_env you can probably do isinstance(env_file, (string_types, os.PathLike)). You'd have to special-case for Python 3.6 vs Python <3.6.

Eventually, I think the whole Path class as implemented by this library can go away.

@gabn88
Copy link

gabn88 commented Feb 25, 2017

Does this mean that symlinks are also allowed?

I like to symlink to an .env-example, so that on production not accidentially the .env is read (it requires a manual step of creating the symlink).

@sergeyklay
Copy link
Collaborator

This is resolved in develop branch. Thank you for the report, and for helping us make django-environ better. And I am sorry about the delay.

@sergeyklay sergeyklay added the enhancement New feature or request label Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants