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

Fix formatter variable referenced before assignment #1432

Merged
merged 2 commits into from
Apr 16, 2020

Conversation

FabioRosado
Copy link
Member

@FabioRosado FabioRosado commented Apr 16, 2020

Description

Moved formatter = logging.Formatter("%(levelname)s %(name)s: %(message)s") line outside try/except block. Removed try/except and added a suppress if KeyError is raised on config['logging']['extended'].

Note: For some reason black and tox didn't run on my end so I was unabled to check tests before raising the PR

Fixes #1429

Status

READY | UNDER DEVELOPMENT | ON HOLD

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Tested bot with extended flag set to true - worked as expected.
  • Tested bot without extended flag set - worked as expected.
  • Ran Travis - all Green

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov
Copy link

codecov bot commented Apr 16, 2020

Codecov Report

Merging #1432 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1432      +/-   ##
==========================================
- Coverage   99.90%   99.90%   -0.01%     
==========================================
  Files          52       52              
  Lines        3059     3058       -1     
==========================================
- Hits         3056     3055       -1     
  Misses          3        3              
Impacted Files Coverage Δ
opsdroid/logging.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1af196f...2d2cb87. Read the comment docs.

try:
formatter = logging.Formatter("%(levelname)s %(name)s: %(message)s")

with contextlib.suppress(KeyError):
Copy link
Contributor

Choose a reason for hiding this comment

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

ooh, useful 😁

@Cadair Cadair merged commit 882ad89 into opsdroid:master Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opsdroid logger returning errors
3 participants