# StellarCN/py-stellar-base

stellar_sdk/client/aiohttp_client.py

### Summary

A
35 mins

#### Cyclomatic complexity is too high in method stream. (13) Open

``````    async def stream(  # type: ignore[override]
self, url: str, params: Dict[str, str] = None
) -> AsyncGenerator[Dict[str, Any], None]:
"""Perform Stream request.

``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Cyclomatic complexity is too high in function __readline. (9) Open

``````async def __readline(self) -> bytes:
if self._exception is not None:
raise self._exception

line = []``````

## Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

#### Function `__init__` has 6 arguments (exceeds 5 allowed). Consider refactoring. Open

``    def __init__(``
Found in stellar_sdk/client/aiohttp_client.py - About 35 mins to fix

#### TODO found Open

``        except aiohttp.ClientError as e:  # TODO: need more research``
Found in stellar_sdk/client/aiohttp_client.py by fixme

#### Line too long (86 > 79 characters) Open

``                url, data=data, timeout=aiohttp.ClientTimeout(total=self.post_timeout)``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (90 > 79 characters) Open

``    :param backoff_factor: a backoff factor to apply between attempts after the second try``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (100 > 79 characters) Open

``                Headers are needed because of a bug that makes "params" override the default headers``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (100 > 79 characters) Open

``                    We want to throw a TimeoutError if we didnt get any event in the last x seconds.``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (118 > 79 characters) Open

``        :raise: :exc:`StreamClientError <stellar_sdk.exceptions.StreamClientError>` - Failed to fetch stream resource.``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (120 > 79 characters) Open

``                    read_timeout in aiohttp is not implemented correctly https://github.com/aio-libs/aiohttp/issues/1954``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (90 > 79 characters) Open

``            # Other headers such as "Accept: text/event-stream" are added by thr SSEClient``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (101 > 79 characters) Open

``                            # Events that dont have an id are not useful for us (hello/byebye events)``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (120 > 79 characters) Open

``                    Note that the timeout starts from the first event forward. There is no until we get the first event.``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````

#### Line too long (127 > 79 characters) Open

``                    f"We have encountered an timeout error and we will try to reconnect, cursor = {query_params.get('cursor')}"``
Found in stellar_sdk/client/aiohttp_client.py by pep8

Limit all lines to a maximum of 79 characters.

``````There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.``````