Repository: PyGithub/PyGithub

Issue:
Repository.edit does not let you set merge commit rule booleans to false
https://github.com/PyGithub/PyGithub/blob/master/github/Repository.py#L1250-L1252 are the offending lines.

The assertions assert that the provided booleans are set to True, so you can never set them to False :)

This is a simple fix to remove that conditional in the assertion, but maybe there was a reason for this?


Discussion:
Thanks for reporting. I believe that's a typo, unless the PR author thinks otherwise @jacquerie ? 

Uhm, it seems like I mindlessly used the same pattern as for `archived`, for which it makes sense to have that assertion because you can't unarchive through the API. So yes, it's a bug that my PR introduced!
Thanks for confirming! Now I am open for a quick PR to fix it :)

________________________________
From: Jacopo Notarstefano <notifications@github.com>
Sent: Sunday, September 16, 2018 7:32:17 PM
To: PyGithub/PyGithub
Cc: Wan Liuyang; Comment
Subject: Re: [PyGithub/PyGithub] Repository.edit does not let you set merge commit rule booleans to false (#903)


Uhm, it seems like I mindlessly used the same pattern as for archived, for which it makes sense to have that assertion because you can't unarchive through the API. So yes, it's a bug that my PR introduced!

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://github.com/PyGithub/PyGithub/issues/903#issuecomment-421749667>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AA-CRra0EvRzkqoC9n7rQowKZ8f0_Htpks5ubjbBgaJpZM4WqBrJ>.


Resolving patch:
diff --git a/github/Repository.py b/github/Repository.py
--- a/github/Repository.py
+++ b/github/Repository.py
@@ -1247,9 +1247,9 @@ def edit(self, name=None, description=github.GithubObject.NotSet, homepage=githu
         assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
         assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
         assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, (str, unicode)), default_branch
-        assert allow_squash_merge is github.GithubObject.NotSet or (isinstance(allow_squash_merge, bool) and allow_squash_merge is True), allow_squash_merge
-        assert allow_merge_commit is github.GithubObject.NotSet or (isinstance(allow_merge_commit, bool) and allow_merge_commit is True), allow_merge_commit
-        assert allow_rebase_merge is github.GithubObject.NotSet or (isinstance(allow_rebase_merge, bool) and allow_rebase_merge is True), allow_rebase_merge
+        assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge
+        assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit
+        assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge
         assert archived is github.GithubObject.NotSet or (isinstance(archived, bool) and archived is True), archived
         post_parameters = {
             "name": name,


Test patch: