From cd1b7b562ab66f19bce01bbf0d635d0eff0fcab4 Mon Sep 17 00:00:00 2001 From: Steve Bachmeier <23350991+stevebachmeier@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:22:33 -0700 Subject: [PATCH] Sbachmei/mic 5399/mypy errors logging manager (#531) --- CHANGELOG.rst | 4 ++++ pyproject.toml | 1 - src/vivarium/framework/logging/manager.py | 16 ++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 63ab36f4..3f651a9c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 05917c39..c09b005a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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', diff --git a/src/vivarium/framework/logging/manager.py b/src/vivarium/framework/logging/manager.py index 358362a9..c8f6fb1c 100644 --- a/src/vivarium/framework/logging/manager.py +++ b/src/vivarium/framework/logging/manager.py @@ -1,10 +1,10 @@ -# mypy: ignore-errors """ ===================== The Logging Subsystem ===================== """ + from __future__ import annotations import loguru @@ -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, @@ -39,13 +39,13 @@ 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 @@ -53,8 +53,8 @@ def get_logger(self, component_name: str = None) -> loguru.Logger: 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)