telegram/request/_requestparameter.py
Function _value_and_input_files_from_input
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
def _value_and_input_files_from_input( # pylint: disable=too-many-return-statements
value: object,
) -> Tuple[object, List[InputFile]]:
"""Converts `value` into something that we can json-dump. Returns two values:
1. the JSON-dumpable value. Maybe be `None` in case the value is an InputFile which must
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function from_input
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def from_input(cls, key: str, value: object) -> "RequestParameter":
"""Builds an instance of this class for a given key-value pair that represents the raw
input as passed along from a method of :class:`telegram.Bot`.
"""
if not isinstance(value, (str, bytes)) and isinstance(value, Sequence):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
Open
return value.to_dict(), []
Avoid too many return
statements within this function. Open
Open
return data, [value.sticker]
Avoid too many return
statements within this function. Open
Open
return value, []
Avoid too many return
statements within this function. Open
Open
return data, [value.media, thumbnail]
Avoid too many return
statements within this function. Open
Open
return data, [value.media]