<commit_before>from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

QUERY = gql("""
    query ($username: String!, $after: String) {
    user(login: $username) {
        starredRepositories(first: 100, after: $after, orderBy: {direction: DESC, field: STARRED_AT}) {
          totalCount
          nodes {
            name
            nameWithOwner
            description
            url
            stargazerCount
            forkCount
            isPrivate
            pushedAt
            updatedAt
            languages(first: 1, orderBy: {field: SIZE, direction: DESC}) {
              edges {
                node {
                  id
                  name
                }
              }
            }
          }
          pageInfo {
            endCursor
            hasNextPage
          }
        }
      }
    }
    """
            )


class Repository:
    def __init__(self, name, description, language, url, stargazer_count, is_private):
        self.name = name
        self.description = description
        self.language = language
        self.url = url
        self.stargazer_count = stargazer_count
        self.is_private = is_private


class GitHubGQL:
    API_URL = "https://api.github.com/graphql"

    def __init__(self, token):
        self.token = token
        headers = {"Authorization": f"Bearer {token}"}
        self.transport = AIOHTTPTransport(url=self.API_URL, headers=headers)
        self.client = Client(transport=self.transport, fetch_schema_from_transport=True)

    def get_user_starred_by_username(self, username: str, after: str = '') -> list[Repository]:
        items = []
        result = self.client.execute(QUERY, variable_values={"username": username, "after": after})

        has_next = result['user']['starredRepositories']['pageInfo']['hasNextPage']
        end_cursor = result['user']['starredRepositories']['pageInfo']['endCursor']
        # total_count = result['user']['starredRepositories']['totalCount']
        for repo in result['user']['starredRepositories']['nodes']:
            name = repo['nameWithOwner']
            description = repo['description'] if repo['description'] else ''
            language = repo['languages']['edges'][0]['node']['name'] if repo['languages']['edges'] else ''
            url = repo['url']
            stargazer_count = repo['stargazerCount']
            is_private = repo['isPrivate']
            items.append(Repository(name, description, language, url, stargazer_count, is_private))

        if has_next:
            items.extend(self.get_user_starred_by_username(username, end_cursor))
        return items<commit_msg>fix type hint<commit_after>from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

QUERY = gql("""
    query ($username: String!, $after: String) {
    user(login: $username) {
        starredRepositories(first: 100, after: $after, orderBy: {direction: DESC, field: STARRED_AT}) {
          totalCount
          nodes {
            name
            nameWithOwner
            description
            url
            stargazerCount
            forkCount
            isPrivate
            pushedAt
            updatedAt
            languages(first: 1, orderBy: {field: SIZE, direction: DESC}) {
              edges {
                node {
                  id
                  name
                }
              }
            }
          }
          pageInfo {
            endCursor
            hasNextPage
          }
        }
      }
    }
    """
            )


class Repository:
    def __init__(self, name, description, language, url, stargazer_count, is_private):
        self.name = name
        self.description = description
        self.language = language
        self.url = url
        self.stargazer_count = stargazer_count
        self.is_private = is_private


class GitHubGQL:
    API_URL = "https://api.github.com/graphql"

    def __init__(self, token):
        self.token = token
        headers = {"Authorization": f"Bearer {token}"}
        self.transport = AIOHTTPTransport(url=self.API_URL, headers=headers)
        self.client = Client(transport=self.transport, fetch_schema_from_transport=True)

    def get_user_starred_by_username(self, username: str, after: str = ''):
        items = []
        result = self.client.execute(QUERY, variable_values={"username": username, "after": after})

        has_next = result['user']['starredRepositories']['pageInfo']['hasNextPage']
        end_cursor = result['user']['starredRepositories']['pageInfo']['endCursor']
        # total_count = result['user']['starredRepositories']['totalCount']
        for repo in result['user']['starredRepositories']['nodes']:
            name = repo['nameWithOwner']
            description = repo['description'] if repo['description'] else ''
            language = repo['languages']['edges'][0]['node']['name'] if repo['languages']['edges'] else ''
            url = repo['url']
            stargazer_count = repo['stargazerCount']
            is_private = repo['isPrivate']
            items.append(Repository(name, description, language, url, stargazer_count, is_private))

        if has_next:
            items.extend(self.get_user_starred_by_username(username, end_cursor))
        return items
{'fraction_non_alphanumeric': 0.11359333585762968, 'fraction_numerical': 0.001893222264293828, 'mean_word_length': 2.163473053892216, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1508963', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1418, 'n_words': 294}