Skip to content

Commit

Permalink
🐍 Pythonic use of or
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHock committed Mar 30, 2020
1 parent 7c32918 commit 6ec6f43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 6 additions & 5 deletions detect_secrets/core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def get_logger(name=None, format_string=None):
:type name: str
:param name: used for declaring log channels.
:type format_string: str
:type format_string: str|None
:param format_string: for custom formatting
"""
logging.captureWarnings(True)
Expand All @@ -18,14 +18,15 @@ def get_logger(name=None, format_string=None):
log.set_debug_level = _set_debug_level.__get__(log)
log.set_debug_level(0)

if not format_string:
format_string = '[%(module)s]\t%(levelname)s\t%(message)s'

# Setting up log formats
log.handlers = []
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(
logging.Formatter(format_string),
logging.Formatter(
format_string
or
'[%(module)s]\t%(levelname)s\t%(message)s',
),
)
log.addHandler(handler)

Expand Down
5 changes: 1 addition & 4 deletions detect_secrets/core/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,9 @@ class PluginDescriptor(
),
):
def __new__(cls, related_args=None, **kwargs):
if not related_args:
related_args = []

return super(PluginDescriptor, cls).__new__(
cls,
related_args=related_args,
related_args=related_args or [],
**kwargs
)

Expand Down

0 comments on commit 6ec6f43

Please sign in to comment.