Visitar URL original
BranchProtection.restrictions raises AttributeError when push restrictions are present · Issue #3526 · PyGithub/PyGithub · GitHub
Skip to content

BranchProtection.restrictions raises AttributeError when push restrictions are present #3526

Open

Description

@Bolt4243

Describe the bug

Accessing BranchProtection.restrictions raises AttributeError: 'dict' object has no attribute 'value' whenever a branch has push restrictions configured.

The restrictions property returns self._restrictions.value, but _useAttributes stores the raw API dict in self._restrictions rather than wrapping it like every other attribute:

if "restrictions" in attributes:  # pragma no branch
    self._restrictions = attributes["restrictions"]   # raw dict, not wrapped

The absent-restrictions case happens to work only because NotSet.value is None, which is why existing tests (asserting restrictions is None) did not catch this.

Traceback

  File ".../github/BranchProtection.py", line 157, in restrictions
    return self._restrictions.value
           ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'value'

Expected behavior

branch_protection.restrictions returns the restrictions dict (users, teams, apps, etc.) when push restrictions are present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions