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

Obviously handle scrub_fields in rollbar.init() #235

Merged
merged 2 commits into from
Jun 15, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def _get_pylons_request():

## public api

def init(access_token, environment='production', **kw):
def init(access_token, environment='production', scrub_fields=list(), **kw):

Choose a reason for hiding this comment

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

This is potentially dangerous.
It's discouraged to define default argument values with mutable objects.

http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you are right!

Copy link
Contributor

Choose a reason for hiding this comment

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

It isn't an issue here because the default isn't used instead it is just a falsey sentinel, but yeah a None would work just as well.

Choose a reason for hiding this comment

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

@rokob
You're right, it isn't used now.
But who knows what will be in future.
Can you guarantee next contributor won't overlook that?

"""
Saves configuration variables in this module's SETTINGS.

Expand All @@ -300,6 +300,8 @@ def init(access_token, environment='production', **kw):

SETTINGS['access_token'] = access_token
SETTINGS['environment'] = environment
if scrub_fields:
SETTINGS['scrub_fields'] = list(scrub_fields)

# Merge the extra config settings into SETTINGS
SETTINGS = dict_merge(SETTINGS, kw)
Expand Down