internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: PyGithub/PyGithub

Issue:
#1986 seems to break setting GitHub base URL
#1986 seems to break setting base URL.

What I did:
```
auth = AppAuthentication(int(os.getenv("GITHUB_APP_ID")),
                         t,
                         int(os.getenv("GITHUB_APP_INSTALLATION_ID")))
g = Github(base_url="https://test.somegit.com/api/v3", app_auth=auth)
```

When I turn on debugger, the base URL for requester seems to be set to api.github.com. Lmk if I am doing something wrong here, thanks!


Discussion:
Looks like the Requester does not pass the base url to `GithubIntegration`:

https://github.com/PyGithub/PyGithub/blob/c7e3ae94214eaa702121d6ff08c92d83af47ebd9/github/Requester.py#L375-L379
https://github.com/PyGithub/PyGithub/blob/c7e3ae94214eaa702121d6ff08c92d83af47ebd9/github/GithubIntegration.py#L19-L26

@dblanchette 

Resolving patch:
diff --git a/github/Requester.py b/github/Requester.py
--- a/github/Requester.py
+++ b/github/Requester.py
@@ -312,6 +312,7 @@ def __init__(
 
         self.__installation_authorization = None
         self.__app_auth = app_auth
+        self.__base_url = base_url
 
         self.__auth_lock = RLock()
 
@@ -333,7 +334,6 @@ def __init__(
         else:
             self.__authorizationHeader = None
 
-        self.__base_url = base_url
         o = urllib.parse.urlparse(base_url)
         self.__hostname = o.hostname
         self.__port = o.port
@@ -375,7 +375,9 @@ def _must_refresh_token(self) -> bool:
     def _get_installation_authorization(self):
         assert self.__app_auth is not None
         integration = GithubIntegration.GithubIntegration(
-            self.__app_auth.app_id, self.__app_auth.private_key
+            self.__app_auth.app_id,
+            self.__app_auth.private_key,
+            base_url=self.__base_url,
         )
         return integration.get_access_token(
             self.__app_auth.installation_id,


Test patch:
Repository: PyGithub/PyGithub

Issue:
v1.58.0 TypeError: create_jwt() got an unexpected keyword argument 'expiration'
The `expiration` keyword argument was removed in v1.58.0. The interface defined in GithubIntegration.pyi is no longer accurate. 


Discussion:
@andrewlarry  Would you mind creating a PR to fix the typing? I'm happy to approve.
@s-t-e-v-e-n-k @sfdye would you say this is a breaking change that should not have been released in a minor version bump, but better for v2.0.0? Shall we add the `expiration` back that overrides the instance expiration and log a deprecation warning until we move to v2.0.0? I am not yet familiar with the policy of this project regarding those changes.
v2.0.0 has had some beta tags, so I'd rather avoid it. We should add it back, I'm not sure we need to deprecate it.
Sure, does not hurt to keep it. Lets make it optional, though.

Resolving patch:
diff --git a/github/GithubIntegration.py b/github/GithubIntegration.py
--- a/github/GithubIntegration.py
+++ b/github/GithubIntegration.py
@@ -90,17 +90,23 @@ def _get_installed_app(self, url):
             completed=True,
         )
 
-    def create_jwt(self):
+    def create_jwt(self, expiration=None):
         """
         Create a signed JWT
         https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app
 
         :return string:
         """
+        if expiration is not None:
+            assert isinstance(expiration, int), expiration
+            assert (
+                Consts.MIN_JWT_EXPIRY <= expiration <= Consts.MAX_JWT_EXPIRY
+            ), expiration
+
         now = int(time.time())
         payload = {
             "iat": now + self.jwt_issued_at,
-            "exp": now + self.jwt_expiry,
+            "exp": now + (expiration if expiration is not None else self.jwt_expiry),
             "iss": self.integration_id,
         }
         encrypted = jwt.encode(payload, key=self.private_key, algorithm="RS256")


Test patch:
diff --git a/tests/GithubIntegration.py b/tests/GithubIntegration.py
--- a/tests/GithubIntegration.py
+++ b/tests/GithubIntegration.py
@@ -61,6 +61,27 @@ def testCreateJWT(self):
         )
         sys.modules["time"].time = self.origin_time
 
+    def testCreateJWTWithExpiration(self):
+        self.origin_time = sys.modules["time"].time
+        sys.modules["time"].time = lambda: 1550055331.7435968
+        github_integration = github.GithubIntegration(
+            integration_id=APP_ID,
+            private_key=PRIVATE_KEY,
+            jwt_expiry=120,
+            jwt_issued_at=-30,
+        )
+        token = github_integration.create_jwt(60)
+        payload = jwt.decode(
+            token,
+            key=PUBLIC_KEY,
+            algorithms=["RS256"],
+            options={"verify_exp": False},
+        )
+        self.assertDictEqual(
+            payload, {"iat": 1550055301, "exp": 1550055391, "iss": APP_ID}
+        )
+        sys.modules["time"].time = self.origin_time
+
     def testGetInstallations(self):
         github_integration = github.GithubIntegration(
             integration_id=APP_ID, private_key=PRIVATE_KEY
Repository: PyGithub/PyGithub

Issue:
Add cryptography as dependency (for app-based auth)
Using [the new app-based auth ](https://github.com/PyGithub/PyGithub/pull/1986) results to the error below when `cryptography` is not installed. It should be added as a dependency of this.

```
Traceback (most recent call last):
  File "***", line 60, in ***
    github = Github(
  File "/usr/local/lib/python3.9/site-packages/github/MainClass.py", line 122, in __init__
    self.__requester = Requester(
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 332, in __init__
    self._refresh_token()
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 396, in _refresh_token
    self.__installation_authorization = self._get_installation_authorization()
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 377, in _get_installation_authorization
    integration = GithubIntegration.GithubIntegration(
  File "/usr/local/lib/python3.9/site-packages/github/GithubIntegration.py", line 52, in __init__
    jwt=self.create_jwt(),
  File "/usr/local/lib/python3.9/site-packages/github/GithubIntegration.py", line 106, in create_jwt
    encrypted = jwt.encode(payload, key=self.private_key, algorithm="RS256")
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jwt.py", line 67, in encode
    return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jws.py", line 152, in encode
    alg_obj = self.get_algorithm_by_name(algorithm_)
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jws.py", line 91, in get_algorithm_by_name
    raise NotImplementedError(
NotImplementedError: Algorithm 'RS256' could not be found. Do you have cryptography installed?
```


Discussion:
We probably need an extra of jwt, looking at the traceback.
@jodelasur maybe you had package `jwt` installed, which conflicts with `PyJWT`, which is a dependency of `PyGithub`?

If you'd uninstall `jwt` and reinstalled `PyGithub`, it should work.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -104,10 +104,11 @@
         python_requires=">=3.7",
         install_requires=[
             "deprecated",
-            "pyjwt>=2.4.0",
+            "pyjwt[crypto]>=2.4.0",
             "pynacl>=1.4.0",
             "requests>=2.14.0",
         ],
-        extras_require={"integrations": ["cryptography"]},
-        tests_require=["cryptography", "httpretty>=1.0.3"],
+        # can be removed, still here to avoid breaking user code
+        extras_require={"integrations": []},
+        tests_require=["httpretty>=1.0.3"],
     )


Test patch:
Repository: PyGithub/PyGithub

Issue:
GithubApp.slug is None due to no `_completeIfNotSet` call
I noticed that when I do the following code, it will print out `None`. I saw that the slug attribute doesn't use `_completeIfNotSet` before returning the value.:

```python
g = Github(jwt="jwt_token_here")
app = g.get_app()
print(f"slug: {app.slug}")
```

https://github.com/PyGithub/PyGithub/blob/master/github/GithubApp.py#L107-L112


Discussion:

Resolving patch:
diff --git a/github/GithubApp.py b/github/GithubApp.py
--- a/github/GithubApp.py
+++ b/github/GithubApp.py
@@ -109,6 +109,7 @@ def slug(self):
         """
         :type: string
         """
+        self._completeIfNotSet(self._slug)
         return self._slug.value
 
     @property
diff --git a/github/MainClass.py b/github/MainClass.py
--- a/github/MainClass.py
+++ b/github/MainClass.py
@@ -804,13 +804,17 @@ def get_app(self, slug=github.GithubObject.NotSet):
         :rtype: :class:`github.GithubApp.GithubApp`
         """
         assert slug is github.GithubObject.NotSet or isinstance(slug, str), slug
+
         if slug is github.GithubObject.NotSet:
+            # with no slug given, calling /app returns the authenticated app,
+            # including the actual /apps/{slug}
+            headers, data = self.__requester.requestJsonAndCheck("GET", "/app")
+            return GithubApp.GithubApp(self.__requester, headers, data, completed=True)
+        else:
+            # with a slug given, we can lazily load the GithubApp
             return GithubApp.GithubApp(
-                self.__requester, {}, {"url": "/app"}, completed=False
+                self.__requester, {}, {"url": f"/apps/{slug}"}, completed=False
             )
-        else:
-            headers, data = self.__requester.requestJsonAndCheck("GET", f"/apps/{slug}")
-            return GithubApp.GithubApp(self.__requester, headers, data, completed=True)
 
 
 # Retrocompatibility


Test patch:
diff --git a/tests/GithubApp.py b/tests/GithubApp.py
--- a/tests/GithubApp.py
+++ b/tests/GithubApp.py
@@ -101,10 +101,6 @@ def testGetPublicApp(self):
     def testGetAuthenticatedApp(self):
         # For this to work correctly in record mode, this test must be run with --auth_with_jwt
         app = self.g.get_app()
-        # At this point the GithubApp object is not complete.
-        # The url should change when the object is completed - after pulling it down
-        # from the github API
-        self.assertEqual(app.url, "/app")
         self.assertEqual(app.created_at, datetime(2020, 8, 1, 17, 23, 46))
         self.assertEqual(app.description, "Sample App to test PyGithub")
         self.assertListEqual(
Repository: PyGithub/PyGithub

Issue:
Add ability to filter collaborators of a repository by permissions
E.g., I want to be able to do this:

```python
gh = Github(TOKEN)
repo = gh.get_repo("some/repo")
for user in repo.get_collaborators(permission='admin'):
    # something
```

This is currently not possible.


Discussion:

Resolving patch:
diff --git a/github/Repository.py b/github/Repository.py
--- a/github/Repository.py
+++ b/github/Repository.py
@@ -2041,20 +2041,29 @@ def get_branches(self) -> PaginatedList[Branch]:
         """
         return PaginatedList(github.Branch.Branch, self._requester, f"{self.url}/branches", None)
 
-    def get_collaborators(self, affiliation: Opt[str] = NotSet) -> PaginatedList[NamedUser]:
+    def get_collaborators(
+        self, affiliation: Opt[str] = NotSet, permission: Opt[str] = NotSet
+    ) -> PaginatedList[NamedUser]:
         """
-        :calls: `GET /repos/{owner}/{repo}/collaborators <https://docs.github.com/en/rest/reference/repos#collaborators>`_
+        :calls: `GET /repos/{owner}/{repo}/collaborators <https://docs.github.com/en/rest/collaborators/collaborators>`_
         :param affiliation: string
+        :param permission: string
         :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser`
         """
 
         url_parameters = dict()
         allowed_affiliations = ["outside", "direct", "all"]
+        allowed_permissions = ["pull", "triage", "push", "maintain", "admin"]
         if is_defined(affiliation):
             assert isinstance(affiliation, str), affiliation
             assert affiliation in allowed_affiliations, f"Affiliation can be one of {', '.join(allowed_affiliations)}"
             url_parameters["affiliation"] = affiliation
 
+        if is_defined(permission):
+            assert isinstance(permission, str), permission
+            assert permission in allowed_permissions, f"permission can be one of {', '.join(allowed_permissions)}"
+            url_parameters["permission"] = permission
+
         return PaginatedList(
             github.NamedUser.NamedUser,
             self._requester,


Test patch:
Repository: InstaPy/InstaPy

Issue:
Error when image has no caption
I got this.

> Traceback (most recent call last):
>   File ".\quickstart.py", line 23, in <module>
>     .like_by_tags(['landscape'], amount=97) \
>   File "C:\Users\em\Desktop\InstaPy-master\instapy\instapy.py", line 271, in like_by_tags
>     self.username, self.like_by_followers_upper_limit, self.like_by_followers_lower_limit)
>   File "C:\Users\em\Desktop\InstaPy-master\instapy\like_util.py", line 144, in check_link
>     image_text = image_text[0]['nodes']['text'] if image_text else None
> KeyError: 'nodes'


Discussion:

Resolving patch:
diff --git a/instapy/like_util.py b/instapy/like_util.py
--- a/instapy/like_util.py
+++ b/instapy/like_util.py
@@ -122,7 +122,7 @@ def check_link(browser, link, dont_like, ignore_if_contains, ignore_users,
       latest_comments = window._sharedData.entry_data.PostPage[0].media.comments.nodes;
       if (latest_comments === undefined) latest_comments = Array();
       owner_comments = latest_comments
-        .filter(item => item.node.owner.username == '{}')
+        .filter(item => item.user.username == '{}')
         .map(item => item.text)
         .reduce((item, total) => item + '\\n' + total, '');
       return owner_comments;
@@ -141,7 +141,7 @@ def check_link(browser, link, dont_like, ignore_if_contains, ignore_users,
   if image_text is None:
     if graphql:
       image_text = media['edge_media_to_comment']['edges']
-      image_text = image_text[0]['nodes']['text'] if image_text else None
+      image_text = image_text[0]['node']['text'] if image_text else None
     else:
       image_text = media['comments']['nodes']
       image_text = image_text[0]['text'] if image_text else None
@@ -164,7 +164,7 @@ def check_link(browser, link, dont_like, ignore_if_contains, ignore_users,
       return True, user_name, is_video, 'Number of followers exceeds limit'
     if like_by_followers_lower_limit and num_followers < like_by_followers_lower_limit:
       return True, user_name, is_video, 'Number of followers does not reach minimum'
-    
+
   print('Link: {}'.format(link.encode('utf-8')))
   print('Description: {}'.format(image_text.encode('utf-8')))
 
@@ -178,7 +178,7 @@ def check_link(browser, link, dont_like, ignore_if_contains, ignore_users,
   image_text = image_text.lower()
   if any((tag.lower() in image_text for tag in dont_like)):
       return True, user_name, is_video, 'Inappropriate'
-    
+
   return False, user_name, is_video, 'None'
 
 


Test patch:
Repository: InstaPy/InstaPy

Issue:
Pagination not working (I got a quick fix-- class was renamed)
Hey the "load more" button class was renamed yielding this error: 'Load button not found, working with current images!'

The issue was a class name change for the "load more"button. I fixed my bot by updating instapy/like_util.py both lines 35 and 115 (they were identical) from:
('//a[contains(@class, "_8imhp _glz1g")]')

to:
('//a[contains(@class, "_1cr2e _epyes")]')
Pagination not working (I got a quick fix-- class was renamed)
Hey the "load more" button class was renamed yielding this error: 'Load button not found, working with current images!'

The issue was a class name change for the "load more"button. I fixed my bot by updating instapy/like_util.py both lines 35 and 115 (they were identical) from:
('//a[contains(@class, "_8imhp _glz1g")]')

to:
('//a[contains(@class, "_1cr2e _epyes")]')


Discussion:
@benvegel I'll look into this.
Do you want to create a PR for this fix?
@benvegel I'll look into this.
Do you want to create a PR for this fix?

Resolving patch:
diff --git a/instapy/like_util.py b/instapy/like_util.py
--- a/instapy/like_util.py
+++ b/instapy/like_util.py
@@ -32,7 +32,7 @@ def get_links_for_location(browser, location, amount, media=None):
     abort = True
     try:
         load_button = body_elem.find_element_by_xpath \
-            ('//a[contains(@class, "_8imhp _glz1g")]')
+            ('//a[contains(@class, "_1cr2e _epyes")]')
     except:
         print('Load button not found, working with current images!')
     else:
@@ -110,7 +110,7 @@ def get_links_for_tag(browser, tag, amount, media=None):
     abort = True
     try:
         load_button = body_elem.find_element_by_xpath \
-            ('//a[contains(@class, "_8imhp _glz1g")]')
+            ('//a[contains(@class, "_1cr2e _epyes")]')
     except:
         print('Load button not found, working with current images!')
     else:


Test patch:
Repository: InstaPy/InstaPy

Issue:
Unfollow with onlyInstapyFollowed=True not working
`session.unfollow_users(amount=5,`  onlyInstapyFollowed=True)`

> Number of people followed automatically remaining: 14
--> Total people unfollowed : 0 

If however **onlyInstapyFollowed is set to False**. The unfollow works.

Before this line I'm just doing login.


Discussion:

Resolving patch:
diff --git a/instapy/unfollow_util.py b/instapy/unfollow_util.py
--- a/instapy/unfollow_util.py
+++ b/instapy/unfollow_util.py
@@ -248,7 +248,7 @@ def follow_through_dialog(browser, user_name, amount, dont_include, login, follo
                 person_followed.append(person)
 
                 button.send_keys("\n")
-                log_followed_pool(login, user_name)
+                log_followed_pool(login, person) 
                 
                 follow_restrict[user_name] = follow_restrict.get(user_name, 0) + 1
 


Test patch:
Repository: InstaPy/InstaPy

Issue:
Index Error 
When trying to Follow users followers I get this index error


```
Traceback (most recent call last):

  File "example.py", line 18, in <module>

    session.follow_user_followers(['timanderic', 'SuperDeluxe'], amount=10, random=False, sleep_delay=0)

  File "/Users/Travis/Documents/GitHub/InstaPy/instapy/instapy.py", line 902, in follow_user_followers

    userFollowed += follow_given_user_followers(self.browser, user, amount, self.dont_include, self.username, self.follow_restrict, random, sleep_delay)

  File "/Users/Travis/Documents/GitHub/InstaPy/instapy/unfollow_util.py", line 435, in follow_given_user_followers

    personFollowed = follow_through_dialog(browser, user_name, amount, dont_include, login, follow_restrict, allfollowing, random, delay, callbacks=[])

  File "/Users/Travis/Documents/GitHub/InstaPy/instapy/unfollow_util.py", line 255, in follow_through_dialog

    .find_elements_by_tag_name("a")[1].text)

IndexError: list index out of range
```


Discussion:
Also having this issue
Is anyone working on this?
Same thing for me
I have the same problem

Resolving patch:
diff --git a/instapy/unfollow_util.py b/instapy/unfollow_util.py
--- a/instapy/unfollow_util.py
+++ b/instapy/unfollow_util.py
@@ -251,8 +251,11 @@ def follow_through_dialog(browser, user_name, amount, dont_include, login, follo
     for person in follow_buttons:
 
         if person and hasattr(person, 'text') and person.text:
-            person_list.append(person.find_element_by_xpath("../../../*")
-                               .find_elements_by_tag_name("a")[1].text)
+            try:
+                person_list.append(person.find_element_by_xpath("../../../*")
+                                   .find_elements_by_tag_name("a")[1].text)
+            except IndexError:
+                pass  # Element list is too short to have a [1] element
 
     if amount >= total_list:
         amount = total_list


Test patch:
Repository: InstaPy/InstaPy

Issue:
Image check error: 'InstaPy' object has no attribute 'clarifai_id'
Hello boys, 

Got an issue while trying to use clarifai with instapy, 
here is my code, basically I would like to have a test on the behavior of clarifai, so just try on two of my friends pictures, I already went on https://www.clarifai.com/demo to get some existing tag on my friends pics
```python
from instapy import InstaPy
insta_username = 'removedtobeposted'
insta_password = 'removedtobeposted'
session = InstaPy(username=insta_username, password=insta_password)
session.login()
session.set_do_comment(True, percentage=100)
session.set_do_like(True, percentage=80)
session.set_use_clarifai(enabled=True, api_key='removedtobepostedhere')
session.clarifai_check_img_for(['nsfw'])
session.clarifai_check_img_for(['landscape', 'nature', 'outdoors', 'beach'], comment=True, comments=['Awesome', 'So beautiful', u':heart_eyes: :100:'])
session.interact_by_users(['user1', 'user2'], amount=5, random=True, media='Photo')
session.end()
```
I tried many things, Do you have any ideas?
Cheers, 
Morgan




Discussion:

Resolving patch:
diff --git a/instapy/instapy.py b/instapy/instapy.py
--- a/instapy/instapy.py
+++ b/instapy/instapy.py
@@ -938,8 +938,7 @@ def interact_by_users(self,
                                 try:
                                     checked_img, temp_comments = (
                                         check_image(self.browser,
-                                                    self.clarifai_id,
-                                                    self.clarifai_secret,
+                                                    self.clarifai_api_key,
                                                     self.clarifai_img_tags,
                                                     self.clarifai_full_match)
                                     )
@@ -1343,8 +1342,7 @@ def like_by_feed(self,
                                             checked_img, temp_comments = (
                                                 check_image(
                                                     self.browser,
-                                                    self.clarifai_id,
-                                                    self.clarifai_secret,
+                                                    self.clarifai_api_key,
                                                     self.clarifai_img_tags,
                                                     self.clarifai_full_match)
                                             )


Test patch: