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

File objects get attribute content-type which must be accessed through getattr #647

Open
dbosk opened this issue Feb 19, 2024 · 2 comments
Labels

Comments

@dbosk
Copy link

dbosk commented Feb 19, 2024

Describe the bug

File objects get attribute content-type which must be accessed through getattr. All other attributes can be accessed by some_file.attribute, but due to the - that doesn't work for the content-type attribute.

To Reproduce

Steps to reproduce the behavior:

Get an attachment from a submission (submission.attachments). Then one must use getattr(attachment, "content-type") to get the content type. But one can access attachment.filename by dot notation.

Expected behavior

I would expect the content-type attribute to be translated to content_type.

Environment information

  • Python version (python --version): Python 3.10.12
  • CanvasAPI version (pip show canvasapi):
Name: canvasapi
Version: 3.2.0
Summary: API wrapper for the Canvas LMS
Home-page: https://github.com/ucfopen/canvasapi
Author: University of Central Florida - Center for Distributed Learning
Author-email: techrangers@ucf.edu
License: MIT License
Location: /home/dbosk/.cache/pypoetry/virtualenvs/canvaslms-WPDgHmeP-py3.10/lib/python3.10/site-packages
Requires: arrow, pytz, requests
Required-by: canvaslms

Additional context

Probably adding a translation of - to _ in CanvasObject.set_attributes should suffice. Not sure if this would break anything.

@dbosk dbosk added the bug label Feb 19, 2024
@OscarSong2003
Copy link

Can I look into this?

@nayanpaa
Copy link

#650 I attempted to solve this issue by editing CanvasObject.set_attributes and adding some test cases. Please let me know if there is anything I need to change.

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

No branches or pull requests

3 participants