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

Code before:
            '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.

        Raises:
            AssertionError. Raised if the response from the request is None.
            requests.HTTPError. Raised if the request fails.
        """
        url = f'{self.base_url}/collaborators'
        response = requests.get(url, headers=self.rest_headers, timeout=10)

        if response is None:

Review comment (suggestion):
This can be simplified to:

```python
issues_list = []
for issue_data in response.json().get('items', []):
```

Code after:
            '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.

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

        Raises:
            AssertionError. Raised if the response from the request is None.
            requests.HTTPError. Raised if the request fails.
        """
        url = f'{self.base_url}/collaborators'