Skip to content

Commit

Permalink
Sbachmei/mic 5399/mypy errors logging manager (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebachmeier authored Nov 6, 2024
1 parent 8c2285a commit cd1b7b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**3.0.18 - TBD/TBD/TBD**

- Fix mypy errors in vivarium/framework/logging/manager.py

**3.0.17 - 11/04/24**

- Fix mypy errors in vivarium/framework/configuration.py
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ exclude = [
'src/vivarium/framework/components/manager.py',
'src/vivarium/framework/components/parser.py',
'src/vivarium/framework/engine.py',
'src/vivarium/framework/logging/manager.py',
'src/vivarium/framework/lookup/manager.py',
'src/vivarium/framework/population/manager.py',
'src/vivarium/framework/population/population_view.py',
Expand Down
16 changes: 8 additions & 8 deletions src/vivarium/framework/logging/manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# mypy: ignore-errors
"""
=====================
The Logging Subsystem
=====================
"""

from __future__ import annotations

import loguru
Expand All @@ -15,8 +15,8 @@


class LoggingManager(Manager):
def __init__(self):
self._simulation_name = None
def __init__(self) -> None:
self._simulation_name: str | None = None

def configure_logging(
self,
Expand All @@ -39,22 +39,22 @@ def _terminal_logging_not_configured() -> bool:
# fragile since it depends on a loguru's internals as well as the stability of code
# paths in vivarium, but both are quite stable at this point, so I think it's pretty,
# low risk.
return 1 not in logger._core.handlers
return 1 not in logger._core.handlers # type: ignore[attr-defined]

@property
def name(self):
def name(self) -> str:
return "logging_manager"

def get_logger(self, component_name: str = None) -> loguru.Logger:
def get_logger(self, component_name: str | None = None) -> loguru.Logger:
bind_args = {"simulation": self._simulation_name}
if component_name:
bind_args["component"] = component_name
return logger.bind(**bind_args)


class LoggingInterface(Interface):
def __init__(self, manager: LoggingManager):
def __init__(self, manager: LoggingManager) -> None:
self._manager = manager

def get_logger(self, component_name: str = None) -> loguru.Logger:
def get_logger(self, component_name: str | None = None) -> loguru.Logger:
return self._manager.get_logger(component_name)

0 comments on commit cd1b7b5

Please # to comment.