Taragolis commented on code in PR #37602:
URL: https://github.com/apache/airflow/pull/37602#discussion_r1498307318
##########
airflow/models/xcom.py:
##########
@@ -785,19 +801,26 @@ def __getstate__(self) -> Any:
return (str(statement), query.count())
def __setstate__(self, state: Any) -> None:
+ """Construct a query by retrieving the statement from the `state` and
assign it to the `self._query`class property."""
statement, self._len = state
self._query = Query(XCom.value).from_statement(text(statement))
def __len__(self):
+ """Declare a `self._len` class property that assigns the number of
rows the query returns using `query.count()` if the `self._len` property is
`None`.
+
+ Otherwise return `self._len`
+ """
if self._len is None:
with self._get_bound_query() as query:
self._len = query.count()
return self._len
def __iter__(self):
+ """Return a `_LazyXComAccessIterator` class instance to manage query
sessions."""
Review Comment:
Better replace by Iterate over the ..., and try to avoid mention
private/internal classes because them not part of the public API
##########
airflow/models/xcom.py:
##########
@@ -785,19 +801,26 @@ def __getstate__(self) -> Any:
return (str(statement), query.count())
def __setstate__(self, state: Any) -> None:
+ """Construct a query by retrieving the statement from the `state` and
assign it to the `self._query`class property."""
statement, self._len = state
self._query = Query(XCom.value).from_statement(text(statement))
def __len__(self):
+ """Declare a `self._len` class property that assigns the number of
rows the query returns using `query.count()` if the `self._len` property is
`None`.
+
+ Otherwise return `self._len`
Review Comment:
Some more specific better here, `__len__` just about length of the object.
Better avoid to detail explanation into the docstring. Implementation could be
changed, and docstring transformed into the "liar"
You could ask a round in `#new-contributors` or `#contributors` slack
channel (join link if you not there https://s.apache.org/airflow-slack) if you
would like what kind of the object it calculate length
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]