Skip to content

Commit

Permalink
Try to please mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Nov 10, 2022
1 parent 8882a23 commit cd76b85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pymech/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
import os
import logging
from typing import Union

logger = logging.getLogger("pymech")

Expand All @@ -23,16 +24,15 @@
# Set a nice colored output
from rich.logging import RichHandler

handler = RichHandler()
logger.addHandler(handler)
handler: Union[RichHandler, logging.StreamHandler] = RichHandler()
except ImportError:
# No color available, use default config
handler = logging.StreamHandler()
formatter = logging.Formatter("%(levelname)s: %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.info("Disabling coloured logs; if needed you should `pip install rich`.")

logger.addHandler(handler)

if bool(os.getenv("PYMECH_DEBUG")):
logger.setLevel(logging.DEBUG)
Expand Down

0 comments on commit cd76b85

Please sign in to comment.