Fix BranchProtection.restrictions raising AttributeError - #3527
Open
Noethix55555 wants to merge 1 commit into
Open
Fix BranchProtection.restrictions raising AttributeError#3527Noethix55555 wants to merge 1 commit into
Noethix55555 wants to merge 1 commit into
Conversation
The restrictions property returns self._restrictions.value, but _useAttributes stored the raw dict instead of wrapping it. When push restrictions are present, accessing the property raised AttributeError: 'dict' object has no attribute 'value'. Wrap the value with _makeDictAttribute like every other attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3526.
Problem
BranchProtection.restrictionsraisesAttributeError: 'dict' object has no attribute 'value'whenever push restrictions are present. The property returnsself._restrictions.value, but_useAttributesstored the raw API dict instead of wrapping it like every other attribute. The absent-restrictions case only worked becauseNotSet.valueisNone.Solution
Wrap the value with
_makeDictAttribute, consistent with how all other attributes are handled:The
_user_push_restrictions/_team_push_restrictionslines are left unchanged since they read raw URL strings and already work.Tests
Added two regression tests in
tests/BranchProtection.pythat construct aBranchProtectionoffline (mock requester, no network):testRestrictionsPopulatedbuilds a populated top-levelrestrictionsobject and assertsbp.restrictions["users"]/["teams"]round-trip.testRestrictionsAbsentasserts an absentrestrictionsstill yieldsNone.The populated test fails on
mainwith the reportedAttributeErrorand passes with the fix.