mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
doc update
This commit is contained in:
@ -120,7 +120,7 @@ characters from strings.
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string/integer/float) Input value
|
||||
value: (string/float) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
@ -139,7 +139,7 @@ characters from strings.
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string) Input value
|
||||
value: (string/integer) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
@ -194,7 +194,7 @@ Reraise the stream exception with annotation or print an error
|
||||
def input_type_check(data: str) -> None
|
||||
```
|
||||
|
||||
Ensure input data is a string
|
||||
Ensure input data is a string. Raises TypeError if not.
|
||||
|
||||
<a id="jc.utils.streaming_input_type_check"></a>
|
||||
|
||||
@ -204,7 +204,8 @@ Ensure input data is a string
|
||||
def streaming_input_type_check(data: Iterable) -> None
|
||||
```
|
||||
|
||||
Ensure input data is an iterable, but not a string or bytes
|
||||
Ensure input data is an iterable, but not a string or bytes. Raises
|
||||
TypeError if not.
|
||||
|
||||
<a id="jc.utils.streaming_line_input_type_check"></a>
|
||||
|
||||
@ -214,7 +215,7 @@ Ensure input data is an iterable, but not a string or bytes
|
||||
def streaming_line_input_type_check(line: str) -> None
|
||||
```
|
||||
|
||||
Ensure each line is a string
|
||||
Ensure each line is a string. Raises TypeError if not.
|
||||
|
||||
<a id="jc.utils.timestamp"></a>
|
||||
|
||||
|
15
jc/utils.py
15
jc/utils.py
@ -5,7 +5,7 @@ import locale
|
||||
import shutil
|
||||
from datetime import datetime, timezone
|
||||
from textwrap import TextWrapper
|
||||
from typing import Dict, Iterable, List, Any, Union, Iterator, Optional
|
||||
from typing import Dict, Iterable, List, Union, Optional
|
||||
|
||||
|
||||
def warning_message(message_lines: List[str]) -> None:
|
||||
@ -134,7 +134,7 @@ def convert_to_int(value: Union[str, float]) -> int:
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string/integer/float) Input value
|
||||
value: (string/float) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
@ -164,7 +164,7 @@ def convert_to_float(value: Union[str, int]) -> float:
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string) Input value
|
||||
value: (string/integer) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
@ -249,19 +249,22 @@ def stream_error(e: BaseException, ignore_exceptions: bool, line: str) -> Dict:
|
||||
|
||||
|
||||
def input_type_check(data: str) -> None:
|
||||
"""Ensure input data is a string"""
|
||||
"""Ensure input data is a string. Raises TypeError if not."""
|
||||
if not isinstance(data, str):
|
||||
raise TypeError("Input data must be a 'str' object.")
|
||||
|
||||
|
||||
def streaming_input_type_check(data: Iterable) -> None:
|
||||
"""Ensure input data is an iterable, but not a string or bytes"""
|
||||
"""
|
||||
Ensure input data is an iterable, but not a string or bytes. Raises
|
||||
TypeError if not.
|
||||
"""
|
||||
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||
raise TypeError("Input data must be a non-string iterable object.")
|
||||
|
||||
|
||||
def streaming_line_input_type_check(line: str) -> None:
|
||||
"""Ensure each line is a string"""
|
||||
"""Ensure each line is a string. Raises TypeError if not."""
|
||||
if not isinstance(line, str):
|
||||
raise TypeError("Input line must be a 'str' object.")
|
||||
|
||||
|
Reference in New Issue
Block a user