gurudesh/pytracebugs huggingface dataset:
# Buggy code
def byUsername(self, username, count=30, **kwargs) -> dict:
    """Returns a dictionary listing TikToks given a user's username.

    :param username: The username of the user.
    :param count: The number of posts to return.
                  Note: seems to only support up to ~2,000
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    data = self.getUserObject(username, proxy=proxy)
    return self.userPosts(
        data["id"],
        data["secUid"],
        count=count,
        proxy=proxy,
        language=language,
        region=region,
        **kwargs,
    )


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def byUsername(self, username, count=30, **kwargs) -> dict:
    """Returns a dictionary listing TikToks given a user's username.

    :param username: The username of the user.
    :param count: The number of posts to return.
                  Note: seems to only support up to ~2,000
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    data = self.getUserObject(username, **kwargs)
    return self.userPosts(
        data["id"],
        data["secUid"],
        count=count,
        **kwargs,
    )
# Buggy code
def userPage(
    self, userID, secUID, page_size=30, minCursor=0, maxCursor=0, **kwargs
) -> dict:
    """Returns a dictionary listing of one page of TikToks given a user's ID and secUID

    :param userID: The userID of the user, which TikTok assigns.
    :param secUID: The secUID of the user, which TikTok assigns.
    :param page_size: The number of posts to return per page.
    :param minCursor: time stamp for the earliest TikTok to retrieve
    :param maxCursor: time stamp for the latest TikTok to retrieve
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)

    api_url = (
        "https://m.tiktok.com/api/item_list/?{}&count={}&id={}&type=1&secUid={}"
        "&minCursor={}&maxCursor={}&sourceType=8&appId=1233&region={}&language={}".format(
            self.__add_new_params__(),
            page_size,
            str(userID),
            str(secUID),
            minCursor,
            maxCursor,
            region,
            language,
        )
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def userPage(
    self, userID, secUID, page_size=30, minCursor=0, maxCursor=0, **kwargs
) -> dict:
    """Returns a dictionary listing of one page of TikToks given a user's ID and secUID

    :param userID: The userID of the user, which TikTok assigns.
    :param secUID: The secUID of the user, which TikTok assigns.
    :param page_size: The number of posts to return per page.
    :param minCursor: time stamp for the earliest TikTok to retrieve
    :param maxCursor: time stamp for the latest TikTok to retrieve
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)

    api_url = (
        "https://m.tiktok.com/api/item_list/?{}&count={}&id={}&type=1&secUid={}"
        "&minCursor={}&maxCursor={}&sourceType=8&appId=1233&region={}&language={}".format(
            self.__add_new_params__(),
            page_size,
            str(userID),
            str(secUID),
            minCursor,
            maxCursor,
            region,
            language,
        )
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)
# Buggy code
def getUserPager(self, username, page_size=30, minCursor=0, maxCursor=0, **kwargs):
    """Returns a generator to page through a user's feed

    :param username: The username of the user.
    :param page_size: The number of posts to return in a page.
    :param minCursor: time stamp for the earliest TikTok to retrieve
    :param maxCursor: time stamp for the latest TikTok to retrieve
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    data = self.getUserObject(username, proxy=proxy)

    while True:
        resp = self.userPage(
            data["id"],
            data["secUid"],
            page_size=page_size,
            maxCursor=maxCursor,
            minCursor=minCursor,
            proxy=proxy,
            language=language,
            region=region,
        )

        try:
            page = resp["items"]
        except KeyError:
            # No mo results
            return

        maxCursor = resp["maxCursor"]

        yield page

        if not resp["hasMore"]:
            return  # all done


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getUserPager(self, username, page_size=30, minCursor=0, maxCursor=0, **kwargs):
    """Returns a generator to page through a user's feed

    :param username: The username of the user.
    :param page_size: The number of posts to return in a page.
    :param minCursor: time stamp for the earliest TikTok to retrieve
    :param maxCursor: time stamp for the latest TikTok to retrieve
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    data = self.getUserObject(username, **kwargs)

    while True:
        resp = self.userPage(
            data["id"],
            data["secUid"],
            page_size=page_size,
            maxCursor=maxCursor,
            minCursor=minCursor,
            **kwargs,
        )

        try:
            page = resp["items"]
        except KeyError:
            # No mo results
            return

        maxCursor = resp["maxCursor"]

        yield page

        if not resp["hasMore"]:
            return  # all done
# Buggy code
def userLikedbyUsername(self, username, count=30, **kwargs) -> dict:
    """Returns a dictionary listing TikToks a user has liked by username.
       Note: The user's likes must be public

    :param username: The username of the user.
    :param count: The number of posts to return.
                  Note: seems to only support up to ~2,000
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    data = self.getUserObject(username, proxy=proxy)
    return self.userLiked(
        data["id"],
        data["secUid"],
        count=count,
        proxy=proxy,
        language=language,
        region=region,
        **kwargs,
    )


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def userLikedbyUsername(self, username, count=30, **kwargs) -> dict:
    """Returns a dictionary listing TikToks a user has liked by username.
       Note: The user's likes must be public

    :param username: The username of the user.
    :param count: The number of posts to return.
                  Note: seems to only support up to ~2,000
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param region: The 2 letter region code.
                   Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    data = self.getUserObject(username, **kwargs)
    return self.userLiked(
        data["id"],
        data["secUid"],
        count=count,
        **kwargs,
    )
# Buggy code
def getMusicObject(self, id, **kwargs) -> dict:
    """Returns a music object for a specific sound id.

    :param id: The sound id to search by.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)

    query = {"musicId": id, "language": language}
    api_url = "{}api/music/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getMusicObject(self, id, **kwargs) -> dict:
    """Returns a music object for a specific sound id.

    :param id: The sound id to search by.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)

    query = {"musicId": id, "language": language}
    api_url = "{}api/music/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)
# Buggy code
def getHashtagObject(self, hashtag, **kwargs) -> dict:
    """Returns a hashtag object.

    :param hashtag: The hashtag to search by.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"challengeName": hashtag, "language": language}
    api_url = "{}api/challenge/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getHashtagObject(self, hashtag, **kwargs) -> dict:
    """Returns a hashtag object.

    :param hashtag: The hashtag to search by.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"challengeName": hashtag, "language": language}
    api_url = "{}api/challenge/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)
# Buggy code
def getHashtagDetails(self, hashtag, **kwargs) -> dict:
    """Returns a hashtag object.

    :param hashtag: The hashtag to search by.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"language": language}
    api_url = "{}node/share/tag/{}?{}&{}".format(
        BASE_URL, quote(hashtag), self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getHashtagDetails(self, hashtag, **kwargs) -> dict:
    """Returns a hashtag object.

    :param hashtag: The hashtag to search by.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"language": language}
    api_url = "{}node/share/tag/{}?{}&{}".format(
        BASE_URL, quote(hashtag), self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)
# Buggy code
def getTikTokById(self, id, **kwargs) -> dict:
    """Returns a dictionary of a specific TikTok.

    :param id: The id of the TikTok you want to get the object for.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    did = kwargs.get("custom_did", None)
    query = {
        "itemId": id,
        "language": language,
    }
    api_url = "{}api/item/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getTikTokById(self, id, **kwargs) -> dict:
    """Returns a dictionary of a specific TikTok.

    :param id: The id of the TikTok you want to get the object for.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    did = kwargs.get("custom_did", None)
    query = {
        "itemId": id,
        "language": language,
    }
    api_url = "{}api/item/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)
# Buggy code
def discoverHashtags(self, **kwargs) -> dict:
    """Discover page, consists challenges (hashtags)

    :param proxy: The IP address of a proxy server.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"noUser": 1, "userCount": 30, "scene": 0}
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)["body"][1]["exploreList"]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def discoverHashtags(self, **kwargs) -> dict:
    """Discover page, consists challenges (hashtags)

    :param proxy: The IP address of a proxy server.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"noUser": 1, "userCount": 30, "scene": 0}
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)["body"][1]["exploreList"]
# Buggy code
def discoverMusic(self, **kwargs) -> dict:
    """Discover page, consists of music

    :param proxy: The IP address of a proxy server.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"noUser": 1, "userCount": 30, "scene": 0}
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)["body"][2]["exploreList"]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def discoverMusic(self, **kwargs) -> dict:
    """Discover page, consists of music

    :param proxy: The IP address of a proxy server.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"noUser": 1, "userCount": 30, "scene": 0}
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)["body"][2]["exploreList"]
# Buggy code
def getUser(self, username, **kwargs) -> dict:
    """Gets the full exposed user object

    :param username: The username of the user.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"uniqueId": username, "language": language}
    api_url = "{}api/user/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, proxy=proxy)["userInfo"]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getUser(self, username, **kwargs) -> dict:
    """Gets the full exposed user object

    :param username: The username of the user.
    :param language: The 2 letter code of the language to return.
                     Note: Doesn't seem to have an affect.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {"uniqueId": username, "language": language}
    api_url = "{}api/user/detail/?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)
    return self.getData(b, **kwargs)["userInfo"]
# Buggy code
def getSuggestedUsersbyID(
    self, userId="6745191554350760966", count=30, **kwargs
) -> list:
    """Returns suggested users given a different TikTok user.

    :param userId: The id of the user to get suggestions for.
    :param count: The amount of users to return.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {
        "noUser": 0,
        "pageId": userId,
        "userId": userId,
        "userCount": count,
        "scene": 15,
    }
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)

    res = []
    for x in self.getData(b, proxy=proxy)["body"][0]["exploreList"]:
        res.append(x["cardItem"])
    return res[:count]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getSuggestedUsersbyID(
    self, userId="6745191554350760966", count=30, **kwargs
) -> list:
    """Returns suggested users given a different TikTok user.

    :param userId: The id of the user to get suggestions for.
    :param count: The amount of users to return.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {
        "noUser": 0,
        "pageId": userId,
        "userId": userId,
        "userCount": count,
        "scene": 15,
    }
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)

    res = []
    for x in self.getData(b, **kwargs)["body"][0]["exploreList"]:
        res.append(x["cardItem"])
    return res[:count]
# Buggy code
def getSuggestedUsersbyIDCrawler(
    self, count=30, startingId="6745191554350760966", **kwargs
) -> list:
    """Crawls for listing of all user objects it can find.

    :param count: The amount of users to crawl for.
    :param startingId: The ID of a TikTok user to start at.
    :param language: The language parameter.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    users = []
    unusedIDS = [startingId]
    while len(users) < count:
        userId = random.choice(unusedIDS)
        newUsers = self.getSuggestedUsersbyID(
            userId=userId, language=language, proxy=proxy
        )
        unusedIDS.remove(userId)

        for user in newUsers:
            if user not in users:
                users.append(user)
                unusedIDS.append(user["id"])

    return users[:count]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getSuggestedUsersbyIDCrawler(
    self, count=30, startingId="6745191554350760966", **kwargs
) -> list:
    """Crawls for listing of all user objects it can find.

    :param count: The amount of users to crawl for.
    :param startingId: The ID of a TikTok user to start at.
    :param language: The language parameter.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    users = []
    unusedIDS = [startingId]
    while len(users) < count:
        userId = random.choice(unusedIDS)
        newUsers = self.getSuggestedUsersbyID(userId=userId, **kwargs)
        unusedIDS.remove(userId)

        for user in newUsers:
            if user not in users:
                users.append(user)
                unusedIDS.append(user["id"])

    return users[:count]
# Buggy code
def getSuggestedHashtagsbyID(
    self, count=30, userId="6745191554350760966", **kwargs
) -> list:
    """Returns suggested hashtags given a TikTok user.

    :param userId: The id of the user to get suggestions for.
    :param count: The amount of users to return.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {
        "noUser": 0,
        "pageId": userId,
        "userId": userId,
        "userCount": count,
        "scene": 15,
    }
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)

    res = []
    for x in self.getData(b, proxy=proxy)["body"][1]["exploreList"]:
        res.append(x["cardItem"])
    return res[:count]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getSuggestedHashtagsbyID(
    self, count=30, userId="6745191554350760966", **kwargs
) -> list:
    """Returns suggested hashtags given a TikTok user.

    :param userId: The id of the user to get suggestions for.
    :param count: The amount of users to return.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {
        "noUser": 0,
        "pageId": userId,
        "userId": userId,
        "userCount": count,
        "scene": 15,
    }
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)

    res = []
    for x in self.getData(b, **kwargs)["body"][1]["exploreList"]:
        res.append(x["cardItem"])
    return res[:count]
# Buggy code
def getSuggestedHashtagsbyIDCrawler(
    self, count=30, startingId="6745191554350760966", **kwargs
) -> list:
    """Crawls for as many hashtags as it can find.

    :param count: The amount of users to crawl for.
    :param startingId: The ID of a TikTok user to start at.
    :param language: The language parameter.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    hashtags = []
    ids = self.getSuggestedUsersbyIDCrawler(
        count=count, startingId=startingId, language=language, proxy=proxy
    )
    while len(hashtags) < count and len(ids) != 0:
        userId = random.choice(ids)
        newTags = self.getSuggestedHashtagsbyID(
            userId=userId["id"], language=language, proxy=proxy
        )
        ids.remove(userId)

        for hashtag in newTags:
            if hashtag not in hashtags:
                hashtags.append(hashtag)

    return hashtags[:count]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getSuggestedHashtagsbyIDCrawler(
    self, count=30, startingId="6745191554350760966", **kwargs
) -> list:
    """Crawls for as many hashtags as it can find.

    :param count: The amount of users to crawl for.
    :param startingId: The ID of a TikTok user to start at.
    :param language: The language parameter.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    hashtags = []
    ids = self.getSuggestedUsersbyIDCrawler(
        count=count, startingId=startingId, **kwargs
    )
    while len(hashtags) < count and len(ids) != 0:
        userId = random.choice(ids)
        newTags = self.getSuggestedHashtagsbyID(userId=userId["id"], **kwargs)
        ids.remove(userId)

        for hashtag in newTags:
            if hashtag not in hashtags:
                hashtags.append(hashtag)

    return hashtags[:count]
# Buggy code
def getSuggestedMusicbyID(
    self, count=30, userId="6745191554350760966", **kwargs
) -> list:
    """Returns suggested music given a TikTok user.

    :param userId: The id of the user to get suggestions for.
    :param count: The amount of users to return.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {
        "noUser": 0,
        "pageId": userId,
        "userId": userId,
        "userCount": count,
        "scene": 15,
    }
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)

    res = []
    for x in self.getData(b, proxy=proxy)["body"][2]["exploreList"]:
        res.append(x["cardItem"])
    return res[:count]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getSuggestedMusicbyID(
    self, count=30, userId="6745191554350760966", **kwargs
) -> list:
    """Returns suggested music given a TikTok user.

    :param userId: The id of the user to get suggestions for.
    :param count: The amount of users to return.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    query = {
        "noUser": 0,
        "pageId": userId,
        "userId": userId,
        "userCount": count,
        "scene": 15,
    }
    api_url = "{}node/share/discover?{}&{}".format(
        BASE_URL, self.__add_new_params__(), urlencode(query)
    )
    b = browser(api_url, **kwargs)

    res = []
    for x in self.getData(b, **kwargs)["body"][2]["exploreList"]:
        res.append(x["cardItem"])
    return res[:count]
# Buggy code
def getSuggestedMusicIDCrawler(
    self, count=30, startingId="6745191554350760966", **kwargs
) -> list:
    """Crawls for hashtags.

    :param count: The amount of users to crawl for.
    :param startingId: The ID of a TikTok user to start at.
    :param language: The language parameter.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    musics = []
    ids = self.getSuggestedUsersbyIDCrawler(
        count=count, startingId=startingId, language=language, proxy=proxy
    )
    while len(musics) < count and len(ids) != 0:
        userId = random.choice(ids)
        newTags = self.getSuggestedMusicbyID(
            userId=userId["id"], language=language, proxy=proxy
        )
        ids.remove(userId)

        for music in newTags:
            if music not in musics:
                musics.append(music)

    return musics[:count]


# Traceback (TypeError)
# Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokApi\tiktok.py", line 373, in byUsername
**kwargs,
TypeError: userPosts() got multiple values for keyword argument 'proxy'

# Fixed code
def getSuggestedMusicIDCrawler(
    self, count=30, startingId="6745191554350760966", **kwargs
) -> list:
    """Crawls for hashtags.

    :param count: The amount of users to crawl for.
    :param startingId: The ID of a TikTok user to start at.
    :param language: The language parameter.
    :param proxy: The IP address of a proxy to make requests from.
    """
    (
        region,
        language,
        proxy,
        maxCount,
    ) = self.__process_kwargs__(kwargs)
    musics = []
    ids = self.getSuggestedUsersbyIDCrawler(
        count=count, startingId=startingId, **kwargs
    )
    while len(musics) < count and len(ids) != 0:
        userId = random.choice(ids)
        newTags = self.getSuggestedMusicbyID(userId=userId["id"], **kwargs)
        ids.remove(userId)

        for music in newTags:
            if music not in musics:
                musics.append(music)

    return musics[:count]
# Buggy code
def top(opts):
    if not ENABLED:
        raise Exception("Could not import tracemalloc")
    lines = opts.lines
    seconds = opts.seconds
    force_start = opts.force_start
    if opts.socket is None:
        socket = ipc.find_sockfile()
    else:
        socket = opts.socket
    client = ipc.Client(socket)
    client = command_interface.IPCCommandInterface(client)
    client = command_client.InteractiveCommandClient(client)

    try:
        if not opts.raw:
            curses.wrapper(
                get_stats, client, limit=lines, seconds=seconds, force_start=force_start
            )
        else:
            raw_stats(client, limit=lines, force_start=force_start)
    except TraceNotStarted:
        print(
            "tracemalloc not started on qtile, start by setting "
            "PYTHONTRACEMALLOC=1 before starting qtile"
        )
        print("or force start tracemalloc now, but you'll lose early traces")
        exit(1)
    except TraceCantStart:
        print("Can't start tracemalloc on qtile, check the logs")
    except KeyboardInterrupt:
        exit(-1)


# Traceback (_curses.error)
$ qtile top --force-start
$ qtile top
Traceback (most recent call last):
File "libqtile/scripts/main.py", line 46, in main
options.func(options)
File "qtile/libqtile/scripts/top.py", line 158, in top
force_start=force_start)
File "/usr/lib/python3.7/curses/__init__.py", line 102, in wrapper
return func(stdscr, *args, **kwds)
File "libqtile/scripts/top.py", line 95, in get_stats
scr.addstr(cnt + 1, 0, '{:<3} {:<40} {:<30}'.format(index, filename, mem))
_curses.error: addwstr() returned ERR

# Fixed code
def top(opts):
    if not ENABLED:
        raise Exception("Could not import tracemalloc")
    lines = opts.lines
    seconds = opts.seconds
    force_start = opts.force_start
    if opts.socket is None:
        socket = ipc.find_sockfile()
    else:
        socket = opts.socket
    client = ipc.Client(socket)
    client = command_interface.IPCCommandInterface(client)
    client = command_client.InteractiveCommandClient(client)

    try:
        if not opts.raw:
            curses.wrapper(
                get_stats, client, limit=lines, seconds=seconds, force_start=force_start
            )
        else:
            raw_stats(client, limit=lines, force_start=force_start)
    except TraceNotStarted:
        print(
            "tracemalloc not started on qtile, start by setting "
            "PYTHONTRACEMALLOC=1 before starting qtile"
        )
        print("or force start tracemalloc now, but you'll lose early traces")
        exit(1)
    except TraceCantStart:
        print("Can't start tracemalloc on qtile, check the logs")
    except KeyboardInterrupt:
        exit(-1)
    except curses.error:
        print("Terminal too small for curses interface.")
        raw_stats(client, limit=lines, force_start=force_start)
# Buggy code
def restart(self):
    argv = [sys.executable] + sys.argv
    if "--no-spawn" not in argv:
        argv.append("--no-spawn")
    buf = io.BytesIO()
    try:
        pickle.dump(QtileState(self), buf, protocol=0)
    except:  # noqa: E722
        logger.error("Unable to pickle qtile state")
    argv = [s for s in argv if not s.startswith("--with-state")]
    argv.append("--with-state=" + buf.getvalue().decode())
    self._restart = (sys.executable, argv)
    self.stop()


# Traceback (UnicodeDecodeError)
2020-08-29 02:09:05,707 ERROR libqtile manager.py:process_key_event():L374 KB command error restart: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/libqtile/command_interface.py", line 312, in call
return SUCCESS, cmd(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/libqtile/core/manager.py", line 1147, in cmd_restart
self.restart()
File "/usr/lib/python3.8/site-packages/libqtile/core/manager.py", line 290, in restart
argv.append('--with-state=' + buf.getvalue().decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 163: invalid continuation byte

# Fixed code
def restart(self):
    argv = [sys.executable] + sys.argv
    if "--no-spawn" not in argv:
        argv.append("--no-spawn")
    state_file = os.path.join(tempfile.gettempdir(), "qtile-state")
    try:
        with open(state_file, "wb") as f:
            pickle.dump(QtileState(self), f, protocol=0)
    except:  # noqa: E722
        logger.error("Unable to pickle qtile state")
    argv = [s for s in argv if not s.startswith("--with-state")]
    argv.append("--with-state=" + state_file)
    self._restart = (sys.executable, argv)
    self.stop()
# Buggy code
def cmd_get_state(self):
    """Get pickled state for restarting qtile"""
    buf = io.BytesIO()
    pickle.dump(QtileState(self), buf, protocol=0)
    state = buf.getvalue().decode()
    logger.debug("State = ")
    logger.debug("".join(state.split("\n")))
    return state


# Traceback (UnicodeDecodeError)
2020-08-29 02:09:05,707 ERROR libqtile manager.py:process_key_event():L374 KB command error restart: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/libqtile/command_interface.py", line 312, in call
return SUCCESS, cmd(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/libqtile/core/manager.py", line 1147, in cmd_restart
self.restart()
File "/usr/lib/python3.8/site-packages/libqtile/core/manager.py", line 290, in restart
argv.append('--with-state=' + buf.getvalue().decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 163: invalid continuation byte

# Fixed code
def cmd_get_state(self):
    """Get pickled state for restarting qtile"""
    buf = io.BytesIO()
    pickle.dump(QtileState(self), buf, protocol=0)
    state = buf.getvalue().decode(errors="backslashreplace")
    logger.debug("State = ")
    logger.debug("".join(state.split("\n")))
    return state
# Buggy code
def __init__(self, **config):
    base.InLoopPollText.__init__(self, **config)
    self.add_defaults(Backlight.defaults)
    self.future = None

    self.brightness_file = os.path.join(
        BACKLIGHT_DIR,
        self.backlight_name,
        self.brightness_file,
    )
    self.max_brightness_file = os.path.join(
        BACKLIGHT_DIR,
        self.backlight_name,
        self.max_brightness_file,
    )
    self.max_value = self._load_file(self.max_brightness_file)
    self.step = self.max_value * self.step / 100


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/libqtile/confreader.py", line 92, in load
config = __import__(name)  # noqa: F811
File "/home/neworld/.config/qtile/config.py", line 363, in <module>
widget.Backlight(
File "/usr/lib/python3.8/site-packages/libqtile/utils.py", line 213, in class_proxy
return cls(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 96, in __init__
self.max_value = self._load_file(self.max_brightness_file)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 105, in _load_file
raise RuntimeError(
RuntimeError: Unable to read status for max_brightness

# Fixed code
def __init__(self, **config):
    base.InLoopPollText.__init__(self, **config)
    self.add_defaults(Backlight.defaults)
    self._future = None

    self.brightness_file = os.path.join(
        BACKLIGHT_DIR,
        self.backlight_name,
        self.brightness_file,
    )
    self.max_brightness_file = os.path.join(
        BACKLIGHT_DIR,
        self.backlight_name,
        self.max_brightness_file,
    )

    mouse_callbacks = {
        "Button4": lambda q: self.cmd_change_backlight(ChangeDirection.UP),
        "Button5": lambda q: self.cmd_change_backlight(ChangeDirection.DOWN),
    }
    mouse_callbacks.update(self.mouse_callbacks)
    self.mouse_callbacks = mouse_callbacks
# Buggy code
def _get_info(self):
    brightness = self._load_file(self.brightness_file)

    info = {
        "brightness": brightness,
        "max": self.max_value,
    }
    return info


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/libqtile/confreader.py", line 92, in load
config = __import__(name)  # noqa: F811
File "/home/neworld/.config/qtile/config.py", line 363, in <module>
widget.Backlight(
File "/usr/lib/python3.8/site-packages/libqtile/utils.py", line 213, in class_proxy
return cls(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 96, in __init__
self.max_value = self._load_file(self.max_brightness_file)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 105, in _load_file
raise RuntimeError(
RuntimeError: Unable to read status for max_brightness

# Fixed code
def _get_info(self):
    brightness = self._load_file(self.brightness_file)
    max_value = self._load_file(self.max_brightness_file)
    return brightness / max_value
# Buggy code
def poll(self):
    try:
        info = self._get_info()
    except RuntimeError as e:
        return "Error: {}".format(e)

    percent = info["brightness"] / info["max"]
    return self.format.format(percent=percent)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/libqtile/confreader.py", line 92, in load
config = __import__(name)  # noqa: F811
File "/home/neworld/.config/qtile/config.py", line 363, in <module>
widget.Backlight(
File "/usr/lib/python3.8/site-packages/libqtile/utils.py", line 213, in class_proxy
return cls(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 96, in __init__
self.max_value = self._load_file(self.max_brightness_file)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 105, in _load_file
raise RuntimeError(
RuntimeError: Unable to read status for max_brightness

# Fixed code
def poll(self):
    try:
        percent = self._get_info()
    except RuntimeError as e:
        return "Error: {}".format(e)

    return self.format.format(percent=percent)
# Buggy code
def cmd_change_backlight(self, direction):
    if self.future and not self.future.done():
        return
    info = self._get_info()
    if not info:
        new = now = self.max_value
    else:
        new = now = info["brightness"]
    if direction is ChangeDirection.DOWN:  # down
        new = max(now - self.step, 0)
    elif direction is ChangeDirection.UP:  # up
        new = min(now + self.step, self.max_value)
    if new != now:
        self.future = self.qtile.run_in_executor(self.change_backlight, new)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/libqtile/confreader.py", line 92, in load
config = __import__(name)  # noqa: F811
File "/home/neworld/.config/qtile/config.py", line 363, in <module>
widget.Backlight(
File "/usr/lib/python3.8/site-packages/libqtile/utils.py", line 213, in class_proxy
return cls(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 96, in __init__
self.max_value = self._load_file(self.max_brightness_file)
File "/usr/lib/python3.8/site-packages/libqtile/widget/backlight.py", line 105, in _load_file
raise RuntimeError(
RuntimeError: Unable to read status for max_brightness

# Fixed code
def cmd_change_backlight(self, direction):
    if self._future and not self._future.done():
        return
    new = now = self._get_info() * 100
    if direction is ChangeDirection.DOWN:
        new = max(now - self.step, 0)
    elif direction is ChangeDirection.UP:
        new = min(now + self.step, 100)
    if new != now:
        self._future = self.qtile.run_in_executor(self._change_backlight, new)
# Buggy code
def when(self, layout=None, when_floating=True):
    self._layout = layout
    self._when_floating = when_floating


# Traceback (AttributeError)
libqtile xcore.py:_xpoll():L277  Got an exception in poll loop
Traceback (most recent call last):
File "/share/git/qtile/libqtile/backend/x11/xcore.py", line 246, in _xpoll
ret = target(event)
File "/share/git/qtile/libqtile/backend/x11/xcore.py", line 494, in handle_KeyPress
self.qtile.process_key_event(keysym, event.state &amp; self._valid_mask)
File "/share/git/qtile/libqtile/core/manager.py", line 342, in process_key_event
if cmd.check(self):
AttributeError: 'NoneType' object has no attribute 'check'

# Fixed code
def when(self, layout=None, when_floating=True):
    self._layout = layout
    self._when_floating = when_floating
    return self