Taragolis commented on code in PR #37757:
URL: https://github.com/apache/airflow/pull/37757#discussion_r1505123675


##########
.pre-commit-config.yaml:
##########
@@ -855,7 +855,7 @@ repos:
         files: ^dev/breeze/.*$
         pass_filenames: false
         require_serial: true
-        additional_dependencies: ['click', 'rich>=12.4.4', 'pyyaml']
+        additional_dependencies: ['click', 'rich>=12.4.4', 'pyyaml', 
'methodtools']

Review Comment:
   Well it was to soon to say that this is a solution, I've create a test for 
check hashing and got and error in all case
   There is different reason for that: __slots__, weakref do not work well with 
this types, recursion error. 
   
   
   ```python
       ...
       def test_hashing(self):
           o = ObjectStoragePath(f"file:///tmp/{str(uuid.uuid4())}")
           s = set()
           for _ in range(10):
               s.add(o)
           assert len(s) == 1
   ```
   
   `@functools.lru_cache`
   ---
   
   ```console
       def test_hashing(self):
           o = ObjectStoragePath(f"file:///tmp/{str(uuid.uuid4())}")
           s = set()
           for _ in range(10):
   >           s.add(o)
   E           RecursionError: maximum recursion depth exceeded while calling a 
Python object
   ```
   
   `@methodtools.lru_cache(max_size=None)`
   ---
   
   ```cosnsole
       def test_hashing(self):
           o = ObjectStoragePath(f"file:///tmp/{str(uuid.uuid4())}")
           s = set()
           for _ in range(10):
   >           s.add(o)
   E           TypeError: unhashable type: 'ObjectStoragePath'
   ```
   
   Use cached property with name defined in `__slots__`
   ---
   
   
   ```console
   tests/io/test_path.py:None (tests/io/test_path.py)
   test_path.py:31: in <module>
       from airflow.io.path import ObjectStoragePath
   ../../airflow/io/path.py:72: in <module>
       class ObjectStoragePath(CloudPath):
   E   ValueError: '_hash' in __slots__ conflicts with class variable
   ```
   
   Use cached property with name not defined in `__slots__`
   ---
   
   ```console
   >           raise TypeError(msg) from None
   E           TypeError: No '__dict__' attribute on 'ObjectStoragePath' 
instance to cache '_awesome_hash' property.
   ```
   
   @bolkedebruin I have a couple questions:
   1. Do we actually need to make ObjectStoragePath hashable?
   2. Do we need to make hash cachable?



-- 
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]

Reply via email to