Behaviour experiencing
User is running a Python Flask application and has implemented Raygun4Py. When the user tries to set the Raygun config, they get the following error:
TypeError: Provider.__init__() got an unexpected keyword argument 'config'
Expected behaviour
When this works, we are expecting the programme to run without error, and the config items set to take effect.
Steps to reproduce
You can pull down this repo that includes a Python test app set up with Flask and Raygun.
This test app has been set up with the 'filtered_keys'
config item being passed through the config object to the provider, but you could use any config item. This is what triggers the error.
You can follow the steps below to set up and run the test app.
Findings
- Tried different syntax for passing the config:
flask.Provider(app, api_key, {'filtered_keys': ['RAYGUN_API_KEY']}).attach()
,flask.Provider(app, api_key, {}).attach()
. Neither of these worked. Instead I got the error:TypeError: Provider.__init__() takes 3 positional arguments but 4 were given
.
Project set up
-
Pull down this repo.
-
Open a terminal in the route directory, install Flask by running
python -m pip install flask
. -
(Optional) Install python-dotenv by running
py -m pip install python-dotenv
. -
(Optional) Add
.env
file that contains your Raygun application API key. -
Pull down the Raygun4Py repo to your computer. Checkout the branch that has the bugfix
ob/worm-51/update-python-middlewear
. -
From the Raygun4Py route directory, run the command
python setup.py sdist
to build the Raygun4Py package. -
Also from this route directory, you can run
python setup.py install
. This will install the local Raygun4Py package so that you can use it in your test app. -
To check that the package has installed correctly, and is available to your project, got to the terminal in the route directory of your project, and run
python -m pip show raygun4py
. -
To run your project, run
python app.py
from the route directory.
You can keep making local changes in the Raygun4Py repo and running the build/install steps to implement and test your changes. I'd recommend changing the version number each time just so you can keep track of which changes you're running. Can always switch back to the correct version before pushing up.