You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "mixilchenko (via GitHub)" <gi...@apache.org> on 2025/10/23 14:26:25 UTC

[PR] Fix iterating through `ObjectStoragePath` [airflow]

mixilchenko opened a new pull request, #57156:
URL: https://github.com/apache/airflow/pull/57156

   Problem: Iterating through `ObjectStoragePath` raises `TypeError: '_io.TextIOWrapper' object is not subscriptable`
   
   This is happening because `_TrackingFileWrapper` implements `__getitem__` which is used by python iteration logic if there is no explicit `__iter__` method.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix iterating through `ObjectStoragePath` [airflow]

Posted by "KoviAnusha (via GitHub)" <gi...@apache.org>.
KoviAnusha commented on code in PR #57156:
URL: https://github.com/apache/airflow/pull/57156#discussion_r2458472180


##########
task-sdk/src/airflow/sdk/io/path.py:
##########
@@ -60,6 +60,9 @@ def wrapper(*args, **kwargs):
 
         return wrapper
 
+    def __iter__(self):
+        return iter(self._obj)
+

Review Comment:
   Delegating iteration to self._obj makes it work seamlessly with Python’s iteration logic. You can also add a short comment/note above explaining why this delegation is needed, so that it helps people who work on this in the future.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix iterating through `ObjectStoragePath` [airflow]

Posted by "bolkedebruin (via GitHub)" <gi...@apache.org>.
bolkedebruin merged PR #57156:
URL: https://github.com/apache/airflow/pull/57156


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix iterating through `ObjectStoragePath` [airflow]

Posted by "mixilchenko (via GitHub)" <gi...@apache.org>.
mixilchenko commented on code in PR #57156:
URL: https://github.com/apache/airflow/pull/57156#discussion_r2459046517


##########
task-sdk/src/airflow/sdk/io/path.py:
##########
@@ -60,6 +60,9 @@ def wrapper(*args, **kwargs):
 
         return wrapper
 
+    def __iter__(self):
+        return iter(self._obj)
+

Review Comment:
   Thanks for the review, sending the suggestion
   ```suggestion
       # We need to explicitly implement `__iter__`
       # because otherwise python iteration logic could use `__getitem__`
       def __iter__(self):
           return iter(self._obj)
   
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix iterating through `ObjectStoragePath` [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #57156:
URL: https://github.com/apache/airflow/pull/57156#issuecomment-3441497693

   cc @bolkedebruin your forte :)


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix iterating through `ObjectStoragePath` [airflow]

Posted by "KoviAnusha (via GitHub)" <gi...@apache.org>.
KoviAnusha commented on code in PR #57156:
URL: https://github.com/apache/airflow/pull/57156#discussion_r2459074670


##########
task-sdk/src/airflow/sdk/io/path.py:
##########
@@ -60,6 +60,9 @@ def wrapper(*args, **kwargs):
 
         return wrapper
 
+    def __iter__(self):
+        return iter(self._obj)
+

Review Comment:
   Looks good to me. Thanks for addressing that quickly!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org