Skip to content

Commit a6fac3d

Browse files
authored
upath.core: handover cached fs instances in with_segments (#516)
1 parent d1b28fd commit a6fac3d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

upath/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ class UPath(_UPathMixin, WritablePath, ReadablePath):
785785
if TYPE_CHECKING: # noqa: C901
786786
_chain: Chain
787787
_chain_parser: FSSpecChainParser
788-
_fs_cached: bool
788+
_fs_cached: AbstractFileSystem
789789
_raw_urlpaths: Sequence[JoinablePathLike]
790790
_relative_base: str | None
791791

@@ -965,6 +965,8 @@ def with_segments(self, *pathsegments: JoinablePathLike) -> Self:
965965
protocol=self._protocol,
966966
**self._storage_options,
967967
)
968+
if hasattr(self, "_fs_cached"):
969+
new_instance._fs_cached = self._fs_cached
968970

969971
if is_relative:
970972
new_instance._relative_base = self._relative_base

0 commit comments

Comments
 (0)