Skip to content

Conversation

hiranya911
Copy link
Contributor

Credential factory functions like credentials.cert() currently only accept str typed file paths. But Python 3.4 introduced the pathlib module and with that a wide range of path-like types. This PR makes it possible to pass these path-like objects directly to our credential factory functions.

import pathlib

path = pathlib.Path('home', 'user', 'firebase.json')
cred = credentials.Cert(path)

Basically we are going to treat anything that is accepted by pathlib.Path as a valid file path. This constructor has good built-in argument validation, and throws TypeError for things that not path-like.

Resolves #501

@hiranya911
Copy link
Contributor Author

As suspected encountering issues with Python 3.5. Instead of implementing an ugly hack, I think a better course of action is to drop Python 3.5 support (which EoL'ed a couple of months ago), and delay this fix until then.

Copy link
Member

@lahirumaramba lahirumaramba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks, Hiranya!

@hiranya911 hiranya911 merged commit dcd3a86 into master Apr 23, 2021
@hiranya911 hiranya911 deleted the hkj-cred-path branch April 23, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pathlib and Django v3.1 Compatibility
2 participants