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: make strings py2 compatible #8396

Merged
merged 2 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions kolibri/core/tasks/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uuid

from django.db import connection as django_connection
from six import string_types

from kolibri.core.tasks.exceptions import UserCancelledError
from kolibri.core.tasks.utils import current_state_tracker
Expand Down Expand Up @@ -175,7 +176,7 @@ def __init__(self, func, *args, **kwargs):
kwargs["cancellable"] = func.cancellable
kwargs["extra_metadata"] = func.extra_metadata.copy()
func = func.func
elif not callable(func) and not isinstance(func, str):
elif not callable(func) and not isinstance(func, string_types):
raise TypeError(
"Cannot create Job for object of type {}".format(type(func))
)
Expand Down Expand Up @@ -296,7 +297,7 @@ def __init__(
raise ValueError("priority must be one of 'regular' or 'high' (string).")
elif not isinstance(permission_classes, list):
raise TypeError("permission_classes must be of list type.")
elif not isinstance(queue, str):
elif not isinstance(queue, string_types):
raise TypeError("queue must be of string type.")

self.func = func
Expand Down
6 changes: 4 additions & 2 deletions kolibri/core/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import uuid
from threading import Thread

from six import string_types

from kolibri.core.tasks import compat


Expand All @@ -22,7 +24,7 @@ def stringify_func(func):
funcstring = "{module}.{funcname}".format(
module=func.__module__, funcname=func.__name__
)
elif isinstance(func, str):
elif isinstance(func, string_types):
funcstring = func
else:
raise TypeError("Can't handle a function of type {}".format(type(func)))
Expand All @@ -38,7 +40,7 @@ def import_stringified_func(funcstring):
:param funcstring: String to try to import
:return: callable
"""
if not isinstance(funcstring, str):
if not isinstance(funcstring, string_types):
raise TypeError("Argument must be a string")

modulestring, funcname = funcstring.rsplit(".", 1)
Expand Down