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

Working with drive objects throws "TypeError: unsupported format string passed to type.__format__" #464

Open
ebob9 opened this issue Nov 12, 2024 · 0 comments · May be fixed by #465
Open

Comments

@ebob9
Copy link

ebob9 commented Nov 12, 2024

The problem

When working with iCloud Drive objects, the str/type/repr functions throw errors. This apparently is due to the "rf" string complexities. I was able to resolve this by replacing "rf" string line in pyicloud with concatenated standard and "f" strings.

Environment

  • pyiCloud release with the issue (pip show pyicloud):
(.venv) ebob9-mac:icloud_drive_bug_workaround ebob9$ pip show pyicloud
Name: pyicloud
Version: 1.0.0
Summary: PyiCloud is a module which allows pythonistas to interact with iCloud webservices.
Home-page: https://github.com/picklepete/pyicloud
Author: 
Author-email: 
License: MIT
Location: /Users/ebob9/Desktop/longterm_project/pub/icloud_drive_bug_workaround/.venv/lib/python3.12/site-packages
Requires: certifi, click, keyring, keyrings.alt, requests, tzlocal
Required-by: 
  • Last working pyiCloud release (if known):
  • Service causing this issue:
    pyicloud DriveNode Class
  • Python version (python -V):
(.venv) ebob9-mac:icloud_drive_bug_workaround ebob9$ python -V
Python 3.12.2
  • Operating environment (project deps/Docker/Windows/etc.):
    MacOS Sequoia w/Python 3.12 (homebrew)

Traceback/Error logs

>>> test1 = api.drive.root
>>> test1
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/ebob9/Desktop/pub/icloud_drive_bug_workaround/.venv/lib/python3.12/site-packages/pyicloud/services/drive.py", line 349, in __repr__
    return f"<{type(self).__name__}: {str(self)}>"
                                      ^^^^^^^^^
  File "/Users/ebob9/Desktop/pub/icloud_drive_bug_workaround/.venv/lib/python3.12/site-packages/pyicloud/services/drive.py", line 346, in __str__
    return rf"\{type: {self.type}, name: {self.name}\}"
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to type.__format__

>>> repr(test1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/ebob9/Desktop/pub/icloud_drive_bug_workaround/.venv/lib/python3.12/site-packages/pyicloud/services/drive.py", line 349, in __repr__
    return f"<{type(self).__name__}: {str(self)}>"
                                      ^^^^^^^^^
  File "/Users/ebob9/Desktop/pub/icloud_drive_bug_workaround/.venv/lib/python3.12/site-packages/pyicloud/services/drive.py", line 346, in __str__
    return rf"\{type: {self.type}, name: {self.name}\}"
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to type.__format__

>>> str(test1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/ebob9/Desktop/pub/icloud_drive_bug_workaround/.venv/lib/python3.12/site-packages/pyicloud/services/drive.py", line 346, in __str__
    return rf"\{type: {self.type}, name: {self.name}\}"
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to type.__format__
>>>

Additional information

Will provide a pull request with a simple fix that worked for me shortly after filing this defect

ebob9 pushed a commit to ebob9/pyicloud that referenced this issue Nov 12, 2024
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

Successfully merging a pull request may close this issue.

1 participant