Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TempFS.__enter__ returns object of type FS instead of TempFS #580

Open
dsoulis opened this issue Nov 10, 2023 · 1 comment
Open

TempFS.__enter__ returns object of type FS instead of TempFS #580

dsoulis opened this issue Nov 10, 2023 · 1 comment

Comments

@dsoulis
Copy link

dsoulis commented Nov 10, 2023

Example

with TempFS() as temp_fs:
   temp_fs_sys_path = temp_fs.root_path  # raises AttributeError since temp_fs is of type FS

To get around this you need to do:
temp_fs_root_sys_path = temp_fs.getsyspath('')

There may be other OSFS/TempFS specific attributes that may fail due to this.
TempFS.__enter__ return type should be TempFS, not FS.

@lurch
Copy link
Contributor

lurch commented Nov 10, 2023

temp_fs.root_path

Neither https://docs.pyfilesystem.org/en/latest/reference/tempfs.html nor https://docs.pyfilesystem.org/en/latest/reference/osfs.html document the .root_path attribute as part of the "public API" ? In fact the example at https://docs.pyfilesystem.org/en/latest/reference/tempfs.html#fs.tempfs.TempFS.close shows

syspath = tmp_fs.getsyspath("/")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants