radioviz.services.typing_helpers
Typing helper service module for radioviz application.
This module provides utility functions for handling optional variables in a statically typed environment. It offers options for runtime checks and static analysis assumptions to simplify code that deals with variables guaranteed to be initialized at runtime but defined as Optional[T] for various reasons.
Module Attributes
Generic type variable for typing helpers. |
Functions
|
Assume that a value is not None for static typing purposes and return it with non-Optional type. |
|
Ensure that a value is not None at runtime and return it with non-Optional type. |
- class radioviz.services.typing_helpers.T
Generic type variable for typing helpers.
alias of TypeVar(‘T’)
- radioviz.services.typing_helpers.assume_not_none(value: T | None) T[source]
Assume that a value is not None for static typing purposes and return it with non-Optional type.
This function performs an assertion within a TYPE_CHECKING block to satisfy the static type checker without introducing runtime overhead. Use this function when you are certain the value is initialized but want to avoid runtime checks.