Credentials.py has been deprecated. API credentials are now stored in the .env file. This is another pull request containing changes that will be included in v3.2.1.
Motivation/Context
I have been procrastinating - a refactor for how API credentials are stored is yet another overdue item on the list. I believe it is bad practice to store sensitive information directly in the source code. I took a page out of Flask's design and created the new .env file so that any kind of integration into scripts would not require the user's credentials to be directly exposed.
Additionally, I should now be able to write more thorough continuous integration tests. With previous iterations, I would have had to hardcode my personal credentials into Credentials.py and send the code over to Travis CI, but now I will be able to set encrypted environment variables and keep my credentials private. These new tests are not included in this pull request - I will create a new one in the future once I complete research on setting the variables and when I finalize the tests.
New Dependencies
python-dotenv==0.15.0
Issue Fix or Enhancement Request
N/A
Type of Change
[x] Code Refactor
[x] This change requires a documentation update
Breaking Change
N/A
List All Changes That Have Been Made
Added
Source code
Created a new .env file to store API credentials.
Changed
Source code
Urs.py no longer pulls API credentials from Credentials.py as it is now deprecated.
Credentials are now read from the .env file.
Minor refactoring within Validation.py to ensure an extra Halo line is not rendered on failed credential validation.
Repository documents
Updated How to Get PRAW Credentials.md to reflect new changes.
Deprecated
Source code
Credentials.py has been replaced with the .env file.
The LogError.log_login decorator has been deprecated due to the refactor within Validation.py.
How Has This Been Tested?
Ran manual tests ensuring the new source code correctly reads the environment variables set within .env.
Overview
Summary
Credentials.py
has been deprecated. API credentials are now stored in the.env
file. This is another pull request containing changes that will be included in v3.2.1.Motivation/Context
I have been procrastinating - a refactor for how API credentials are stored is yet another overdue item on the list. I believe it is bad practice to store sensitive information directly in the source code. I took a page out of Flask's design and created the new
.env
file so that any kind of integration into scripts would not require the user's credentials to be directly exposed.Additionally, I should now be able to write more thorough continuous integration tests. With previous iterations, I would have had to hardcode my personal credentials into
Credentials.py
and send the code over to Travis CI, but now I will be able to set encrypted environment variables and keep my credentials private. These new tests are not included in this pull request - I will create a new one in the future once I complete research on setting the variables and when I finalize the tests.New Dependencies
Issue Fix or Enhancement Request
N/A
Type of Change
Breaking Change
N/A
List All Changes That Have Been Made
Added
.env
file to store API credentials.Changed
Urs.py
no longer pulls API credentials fromCredentials.py
as it is now deprecated..env
file.Validation.py
to ensure an extra Halo line is not rendered on failed credential validation.How to Get PRAW Credentials.md
to reflect new changes.Deprecated
Credentials.py
has been replaced with the.env
file.LogError.log_login
decorator has been deprecated due to the refactor withinValidation.py
.How Has This Been Tested?
.env
.Test Configuration
Python version: 3.9.2
See
.travis.yml
for full test configuration.Dependencies
Checklist