Skip to content

obj_or_str improperly rejects strings #715

@Thetwam

Description

@Thetwam

We have a utility function called obj_or_id that is used across the library. It is designed to allow the user to provide either the canvas ID of an resource as an int, or let the library find the ID from an object automatically.

We also have a function called obj_or_str that appears to attempt doing a similar thing, albeit with type of str instead of int. Despite looking similar, it doesn't actually respect the user passing in a str. While the docstring for obj_or_str doesn't claim to work like obj_or_id, it's clear from usage in other functions that we expected it to.

It looks like obj_or_str has limited reach - only on functions related to canvasapi.feature.Feature objects:

  • canvasapi.account.Account.get_feature_flag()
  • canvasapi.course.Course.get_feature_flag()
  • canvasapi.feature.FeatureFlag.delete()
  • canvasapi.feature.FeatureFlag.set_feature_flag()
  • canvasapi.user.User.get_feature_flag()

Update obj_or_str to be more in line with obj_or_id.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions