titus.signature.Lifespan

class titus.signature.Lifespan(birth, deprecation, death, contingency)[source]

Bases: object

Describes the range of support of a function signature (or, in the future, special form) in terms of an optional beginning of life (birth), and optional deprecation and end of life (death).

If a deprecation is specified, a death must be as well, and vice-versa. Whether or not a birth is specified is independent.

At a given titus.signature.PFAVersion, the Lifespan has three possible states: current (method current returns True), deprecated (method deprecated returns True), and non-existent (both current and deprecated return False). Method current and deprecated are mutually exclusive; for a given titus.signature.PFAVersion, they would never both return True.

__init__(birth, deprecation, death, contingency)

Create a Lifespan from a birth, deprecation, death, and contingency.

Parameters:
  • birth (titus.signature.PFAVersion or None) – first PFA version number in which this signature (or special form) is valid; None means the beginning of time
  • deprecation (titus.signature.PFAVersion or None) – first PFA version number in which this signature should raise a deprecation warning; None means never
  • death (titus.signature.PFAVersion or None) – first PFA version number in which this signature is skipped over as not existing; None means the end of time
  • contingency (string or None) – message to accompany the deprecation warning; usually tells the user which function to use instead
current(now)
Parameters:now (titus.signature.PFAVersion) – the version number to query
Return type:bool
Returns:True if the feature exists and is not deprecated in version now, False otherwise.
deprecated(now)
Parameters:now (titus.signature.PFAVersion) – the version number to query
Return type:bool
Returns:True if the feature exists and is deprecated in version now, False otherwise.