Repository: oppia/oppia
File: scripts/inactive_issue_checker.py (Python)

Code before:
        self.token = token
        self.repo_owner = repo_owner
        self.repo_name = repo_name
        self.rest_headers = {
            'Authorization': f'token {token}',
            'Accept': 'application/vnd.github.v3+json'
        }
        self.graphql_headers = {
            'Authorization': f'Bearer {token}',
            'Content-Type': 'application/json'
        }
        self.base_url = f'https://api.github.com/repos/{repo_owner}/{repo_name}'

    def get_open_issues(self) -> List[Issue]:
        """Fetches all open issues from GitHub.

        Returns:
            List[Issue]. List of open issues.

        Raises:
            AssertionError. Raised if the response from the request is None.
            requests.HTTPError. Raised if the request fails.
        """
        search_url = 'https://api.github.com/search/issues'
        end = 'is:issue+state:open'
        url = f'{search_url}?q=repo:{self.repo_owner}/{self.repo_name}+{end}'
        response = requests.get(url, headers=self.rest_headers, timeout=10)
        if response is None:
            raise AssertionError('Received null res while fetching issues')
        response.raise_for_status()

        response_data = response.json()
        issues_list = []
        for issue_data in response_data.get('items', []):
            assert isinstance(issue_data, dict)
            typed_issue_data: IssueDict = {
                'number': issue_data['number'],
                'assignee': issue_data.get('assignee'),
                'events_url': issue_data['events_url']
            }
            issue = Issue.from_github_data(typed_issue_data)
            issues_list.append(issue)

        return issues_list

    def get_repo_collaborators(self) -> set[str]:
        """Fetches repository collaborators.

        Returns:
            set[str]. Set of collaborator usernames.


Review comment (suggestion):
```suggestion
        url = f'{search_url}?q=repo:{self.repo_owner}/{self.repo_name}+is:issue+state:open'
```

why not just include `end` in the `url` template? Unlike `search_url`, I don't see much readability benefit to using an intermediate variable

Code after:
        self.token = token
        self.repo_owner = repo_owner
        self.repo_name = repo_name
        self.rest_headers = {
            'Authorization': f'token {token}',
            'Accept': 'application/vnd.github.v3+json'
        }
        self.graphql_headers = {
            'Authorization': f'Bearer {token}',
            'Content-Type': 'application/json'
        }
        self.base_url = f'https://api.github.com/repos/{repo_owner}/{repo_name}'

    def get_open_issues(self) -> List[Issue]:
        """Fetches all open issues from GitHub.

        Returns:
            List[Issue]. List of open issues.

        Raises:
            AssertionError. Raised if the response from the request is None.
            requests.HTTPError. Raised if the request fails.
        """
        search_url = 'https://api.github.com/search/issues'

        url = (
            f'{search_url}?q=repo:{self.repo_owner}/'
            f'{self.repo_name}+is:issue+state:open'
        )
        print(url, 'is the url')
        response = requests.get(url, headers=self.rest_headers, timeout=10)
        if response is None:
            raise AssertionError('Received null res while fetching issues')
        response.raise_for_status()

        issues_list = []
        for issue_data in response.json().get('items', []):
            assert isinstance(issue_data, dict)
            typed_issue_data: IssueDict = {
                'number': issue_data['number'],
                'assignee': issue_data.get('assignee'),
                'events_url': issue_data['events_url']
            }
            issue = Issue.from_github_data(typed_issue_data)
            issues_list.append(issue)

        return issues_list

    def get_repo_collaborators(self) -> set[str]:
        """Fetches repository collaborators.