In Python 3.11 (currently slated for release in October 2022), pathlib accessors have been removed (see https://bugs.python.org/issue43012), resulting in UPath breaking.
For example, with an s3 remote mocked with moto (pip install moto[server])
$ moto_server s3
* Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
from upath import UPath
path = UPath("s3://bucketname")
path.mkdir()
FileNotFoundError Traceback (most recent call last)
----> 1 u.mkdir()
File /usr/lib/python3.10/pathlib.py:1175, in Path.mkdir(self, mode, parents, exist_ok)
1171 """
1172 Create a new directory at this given path.
1173 """
1174 try:
-> 1175 self._accessor.mkdir(self, mode)
1176 except FileNotFoundError:
1177 if not parents or self.parent == self:
FileNotFoundError: [Errno 2] No such file or directory: 's3://bucketname/'
or, trying to write something to a file:
f = path / "file"
f.write_text("ciao")
Traceback (most recent call last)
----> 1 f.write_text("ciao")
File /usr/lib/python3.10/pathlib.py:1154, in Path.write_text(self, data, encoding, errors, newline)
1151 raise TypeError('data must be str, not %s' %
1152 data.__class__.__name__)
1153 encoding = io.text_encoding(encoding)
-> 1154 with self.open(mode='w', encoding=encoding, errors=errors, newline=newline) as f:
1155 return f.write(data)
File universal_pathlib/upath/core.py:168, in UPath.open(self, *args, **kwargs)
167 def open(self, *args, **kwargs):
--> 168 return self.fs.open(self, *args, **kwargs)
File universal_pathlib/upath/core.py:122, in UPath.__getattr__(self, item)
120 return _accessor
121 else:
--> 122 raise AttributeError(item)
AttributeError: fs
In Python 3.11 (currently slated for release in October 2022), pathlib accessors have been removed (see https://bugs.python.org/issue43012), resulting in UPath breaking.
For example, with an s3 remote mocked with
moto
(pip install moto[server]
)or, trying to write something to a file: