Skip to content

Commit

Permalink
Remove methodtools from the Airflow Core
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis committed Feb 27, 2024
1 parent 38cebe4 commit 77be0ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions airflow/io/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from pathlib import PurePath
from urllib.parse import urlsplit

import methodtools
from fsspec.core import split_protocol
from fsspec.utils import stringify_path
from upath.implementations.cloud import CloudPath, _CloudAccessor
Expand Down Expand Up @@ -152,9 +151,10 @@ def __new__(

return cls._from_parts(args_list, url=parsed_url, conn_id=conn_id, **kwargs) # type: ignore

@methodtools.lru_cache(maxsize=None)
def __hash__(self) -> int:
return hash(str(self))
if not (_hash := getattr(self, "_hash", None)):
self._hash = _hash = hash(str(self))
return _hash

def __eq__(self, other: typing.Any) -> bool:
return self.samestore(other) and str(self) == str(other)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ dependencies = [
"markupsafe>=1.1.1",
"marshmallow-oneofschema>=2.0.1",
"mdit-py-plugins>=0.3.0",
"methodtools>=0.4.7",
"opentelemetry-api>=1.15.0",
"opentelemetry-exporter-otlp",
"packaging>=14.0",
Expand Down
7 changes: 7 additions & 0 deletions tests/io/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,10 @@ def test_dataset(self):
o = ObjectStoragePath(i)
assert o.protocol == p
assert o.path == f

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

0 comments on commit 77be0ea

Please sign in to comment.