Use Optional[] instead of | None
This commit is contained in:
parent
39b850bc3d
commit
003c851e40
1 changed files with 16 additions and 16 deletions
|
@ -343,7 +343,7 @@ period.
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import math
|
import math
|
||||||
import statistics
|
import statistics
|
||||||
from typing import Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
import grpc
|
import grpc
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ class ChannelContext:
|
||||||
self.channel = None
|
self.channel = None
|
||||||
|
|
||||||
|
|
||||||
def call_with_channel(function, *args, context: ChannelContext = None, **kwargs):
|
def call_with_channel(function, *args, context: Optional[ChannelContext] = None, **kwargs):
|
||||||
"""Call a function with a channel object.
|
"""Call a function with a channel object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -437,7 +437,7 @@ def call_with_channel(function, *args, context: ChannelContext = None, **kwargs)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def status_field_names(context: ChannelContext | None = None):
|
def status_field_names(context: Optional[ChannelContext] = None):
|
||||||
"""Return the field names of the status data.
|
"""Return the field names of the status data.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -491,7 +491,7 @@ def status_field_names(context: ChannelContext | None = None):
|
||||||
], alert_names
|
], alert_names
|
||||||
|
|
||||||
|
|
||||||
def status_field_types(context: ChannelContext | None = None):
|
def status_field_types(context: Optional[ChannelContext] = None):
|
||||||
"""Return the field types of the status data.
|
"""Return the field types of the status data.
|
||||||
|
|
||||||
Return the type classes for each field. For sequence types, the type of
|
Return the type classes for each field. For sequence types, the type of
|
||||||
|
@ -541,7 +541,7 @@ def status_field_types(context: ChannelContext | None = None):
|
||||||
], [bool] * len(dish_pb2.DishAlerts.DESCRIPTOR.fields)
|
], [bool] * len(dish_pb2.DishAlerts.DESCRIPTOR.fields)
|
||||||
|
|
||||||
|
|
||||||
def get_status(context: ChannelContext | None = None):
|
def get_status(context: Optional[ChannelContext] = None):
|
||||||
"""Fetch status data and return it in grpc structure format.
|
"""Fetch status data and return it in grpc structure format.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -563,7 +563,7 @@ def get_status(context: ChannelContext | None = None):
|
||||||
return call_with_channel(grpc_call, context=context)
|
return call_with_channel(grpc_call, context=context)
|
||||||
|
|
||||||
|
|
||||||
def get_id(context: ChannelContext | None = None):
|
def get_id(context: Optional[ChannelContext] = None):
|
||||||
"""Return the ID from the dish status information.
|
"""Return the ID from the dish status information.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -584,7 +584,7 @@ def get_id(context: ChannelContext | None = None):
|
||||||
raise GrpcError(e)
|
raise GrpcError(e)
|
||||||
|
|
||||||
|
|
||||||
def status_data(context: ChannelContext | None = None):
|
def status_data(context: Optional[ChannelContext] = None):
|
||||||
"""Fetch current status data.
|
"""Fetch current status data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -812,7 +812,7 @@ def history_stats_field_types():
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_history(context: ChannelContext | None = None):
|
def get_history(context: Optional[ChannelContext] = None):
|
||||||
"""Fetch history data and return it in grpc structure format.
|
"""Fetch history data and return it in grpc structure format.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -881,7 +881,7 @@ def _compute_sample_range(history, parse_samples: int, start: int | None = None,
|
||||||
return sample_range, current - start, current
|
return sample_range, current - start, current
|
||||||
|
|
||||||
|
|
||||||
def concatenate_history(history1, history2, samples1: int = -1, start1: int = None, verbose: bool = False):
|
def concatenate_history(history1, history2, samples1: int = -1, start1: Optional[int] = None, verbose: bool = False):
|
||||||
"""Append the sample-dependent fields of one history object to another.
|
"""Append the sample-dependent fields of one history object to another.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -940,7 +940,7 @@ def concatenate_history(history1, history2, samples1: int = -1, start1: int = No
|
||||||
return unwrapped
|
return unwrapped
|
||||||
|
|
||||||
|
|
||||||
def history_bulk_data(parse_samples: int, start: int | None = None, verbose: bool = False, context: ChannelContext | None = None, history=None):
|
def history_bulk_data(parse_samples: int, start: int | None = None, verbose: bool = False, context: Optional[ChannelContext] = None, history=None):
|
||||||
"""Fetch history data for a range of samples.
|
"""Fetch history data for a range of samples.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -1014,12 +1014,12 @@ def history_bulk_data(parse_samples: int, start: int | None = None, verbose: boo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def history_ping_stats(parse_samples: int, verbose: bool = False, context: ChannelContext = None):
|
def history_ping_stats(parse_samples: int, verbose: bool = False, context: Optional[ChannelContext] = None):
|
||||||
"""Deprecated. Use history_stats instead."""
|
"""Deprecated. Use history_stats instead."""
|
||||||
return history_stats(parse_samples, verbose=verbose, context=context)[0:3]
|
return history_stats(parse_samples, verbose=verbose, context=context)[0:3]
|
||||||
|
|
||||||
|
|
||||||
def history_stats(parse_samples: int, start: int | None = None, verbose: bool = False, context: ChannelContext | None = None, history=None):
|
def history_stats(parse_samples: int, start: int | None = None, verbose: bool = False, context: Optional[ChannelContext] = None, history=None):
|
||||||
"""Fetch, parse, and compute ping and usage stats.
|
"""Fetch, parse, and compute ping and usage stats.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -1205,7 +1205,7 @@ def history_stats(parse_samples: int, start: int | None = None, verbose: bool =
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_obstruction_map(context: ChannelContext | None = None):
|
def get_obstruction_map(context: Optional[ChannelContext] = None):
|
||||||
"""Fetch obstruction map data and return it in grpc structure format.
|
"""Fetch obstruction map data and return it in grpc structure format.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -1228,7 +1228,7 @@ def get_obstruction_map(context: ChannelContext | None = None):
|
||||||
return call_with_channel(grpc_call, context=context)
|
return call_with_channel(grpc_call, context=context)
|
||||||
|
|
||||||
|
|
||||||
def obstruction_map(context: ChannelContext | None = None):
|
def obstruction_map(context: Optional[ChannelContext] = None):
|
||||||
"""Fetch current obstruction map data.
|
"""Fetch current obstruction map data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -1253,7 +1253,7 @@ def obstruction_map(context: ChannelContext | None = None):
|
||||||
return tuple((map_data.snr[i:i + cols]) for i in range(0, cols * map_data.num_rows, cols))
|
return tuple((map_data.snr[i:i + cols]) for i in range(0, cols * map_data.num_rows, cols))
|
||||||
|
|
||||||
|
|
||||||
def reboot(context: ChannelContext | None = None) -> None:
|
def reboot(context: Optional[ChannelContext] = None) -> None:
|
||||||
"""Request dish reboot operation.
|
"""Request dish reboot operation.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -1279,7 +1279,7 @@ def reboot(context: ChannelContext | None = None) -> None:
|
||||||
raise GrpcError(e)
|
raise GrpcError(e)
|
||||||
|
|
||||||
|
|
||||||
def set_stow_state(unstow: bool = False, context: ChannelContext | None = None) -> None:
|
def set_stow_state(unstow: bool = False, context: Optional[ChannelContext] = None) -> None:
|
||||||
"""Request dish stow or unstow operation.
|
"""Request dish stow or unstow operation.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
Loading…
Reference in a new issue