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

Fix polymodel class_ type inconsistency (#89) #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spiqueras
Copy link

Fixes #89 by modifying the return type of class_map_ to always return a list of strings

  • Tests pass
  • [ ] Appropriate changes to README are included in PR (not applicable)

@google-cla
Copy link

google-cla bot commented Jul 3, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -193,7 +193,7 @@ def _update_kind_map(cls):
cls._kind_map[cls._class_name()] = cls
class_key = cls._class_key()
if class_key:
cls._class_map[tuple(class_key)] = cls
cls._class_map[tuple(map(six.ensure_binary, class_key))] = cls
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone with six.ensure_binary because that's what _class_key was using.

Given the library isn't PY2-compatible and assuming _class_key always returns a list of str, a lambda should be faster:

Suggested change
cls._class_map[tuple(map(six.ensure_binary, class_key))] = cls
cls._class_map[tuple(map(lambda c: c.encode(), class_key))] = cls

@spiqueras spiqueras force-pushed the polymodel-class-name branch from beb333e to a905b13 Compare August 7, 2023 06:42
@spiqueras
Copy link
Author

Gentle ping. Is there anything I can do to move this forward?

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 this pull request may close these issues.

Polymodel instances' class_ attribute should contain a list of str objects on creation
1 participant