diff --git a/pyproject.toml b/pyproject.toml index d4974cb..5bdbde6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,7 +126,12 @@ deps = -e{toxinidir} mypy mitogen -commands = mypy -p suitable +commands = + mypy -p suitable --python-version 3.8 + mypy -p suitable --python-version 3.9 + mypy -p suitable --python-version 3.10 + mypy -p suitable --python-version 3.11 + mypy -p suitable --python-version 3.12 [testenv:report] deps = diff --git a/src/suitable/module_runner.py b/src/suitable/module_runner.py index 8d204b1..6ccc865 100644 --- a/src/suitable/module_runner.py +++ b/src/suitable/module_runner.py @@ -34,6 +34,15 @@ from suitable.api import Api +if sys.version_info >= (3, 11): + from datetime import UTC + + def utcnow() -> datetime: + return datetime.now(UTC) +else: + utcnow = datetime.utcnow + + @contextmanager def ansible_verbosity(verbosity: int) -> Generator[None, None, None]: """ Temporarily changes the ansible verbosity. Relies on a single display @@ -215,7 +224,7 @@ def execute(self, *args: Any, **kwargs: Any) -> RunnerResults: } try: - start = datetime.utcnow() + start = utcnow() task_queue_manager = None callback = SilentCallbackModule() @@ -297,7 +306,7 @@ def execute(self, *args: Any, **kwargs: Any) -> RunnerResults: GlobalCLIArgs) GlobalCLIArgs._Singleton__instance = None - log.debug(f'took {datetime.utcnow() - start} to complete') + log.debug(f'took {utcnow() - start} to complete') return self.evaluate_results(callback)