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

AttributeError: _cparts #202

Closed
juftin opened this issue Feb 28, 2024 · 1 comment · Fixed by #203
Closed

AttributeError: _cparts #202

juftin opened this issue Feb 28, 2024 · 1 comment · Fixed by #203
Labels
bug 🐛 Something isn't working compatibility 🤝 Compatibility with stdlib pathlib

Comments

@juftin
Copy link
Contributor

juftin commented Feb 28, 2024

When upgrading to the new version of universal-pathlib I'm finding it common in my use case for tools to compare UPath instances to pathlib.Path instances and raise an AttributeError:

import pathlib

from upath import UPath

github_path = UPath("github://fsspec:universal_pathlib@main/README.md")
local_path = pathlib.Path("README.md")

match = github_path == local_path
  File "/Users/juftin/Library/Application Support/JetBrains/IntelliJIdea2023.2/scratches/scratch_68.py", line 8, in <module>
    match = github_path == local_path
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juftin/.pyenv/versions/3.11.3/lib/python3.11/pathlib.py", line 581, in __eq__
    return self._cparts == other._cparts and self._flavour is other._flavour
                           ^^^^^^^^^^^^^
  File "/Users/juftin/git/textual-universal-directorytree/.venv/test/lib/python3.11/site-packages/upath/core.py", line 421, in __getattr__
    raise AttributeError(item)
AttributeError: _cparts. Did you mean: '_parts'?

I'm not exactly sure what pathlib is doing with _cparts, but I'm finding that implementing _cparts and returning self._parts resolves this issue.

@ap-- ap-- added bug 🐛 Something isn't working compatibility 🤝 Compatibility with stdlib pathlib labels Feb 29, 2024
@ap-- ap-- closed this as completed in #203 Mar 3, 2024
@ap--
Copy link
Collaborator

ap-- commented Mar 3, 2024

Thanks for reporting @juftin !
The fix will be included in the next version 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working compatibility 🤝 Compatibility with stdlib pathlib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants