Skip to content

Commit

Permalink
Annotate with Any for Python 3.7 and 3.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoophalab committed Feb 27, 2025
1 parent 351cc47 commit f0e6773
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/clp_logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,14 @@ def update(self, loglevel: int, log_timestamp_ms: int, log_fn: Callable[[str], N
self.soft_timeout_thread.start()


def _get_mutex_context_from_loglevel_timeout(
loglevel_timeout: Optional[CLPLogLevelTimeout],
) -> AbstractContextManager[Optional[bool]]:
def _get_mutex_context_from_loglevel_timeout(loglevel_timeout: Optional[CLPLogLevelTimeout]) -> Any:
"""
Gets a mutual exclusive context manager for IR stream access.
The return type should be `AbstractContextManager[Optional[bool]]`, but it
is annotated as `Any` for backward compatibility, since the generic
`AbstractContextManager` is not available before Python 3.9 (#18239).
:param loglevel_timeout: An optional `CLPLogLevelTimeout` object.
:return: A context manager that either provides the lock from
`loglevel_timeout` or a `nullcontext` if `loglevel_timeout` is `None`.
Expand Down

0 comments on commit f0e6773

Please sign in to comment.