Skip to content

Commit

Permalink
Merge pull request #64 from nmpowell/rename-interface-attribute
Browse files Browse the repository at this point in the history
resolve conflict between Resource .interface attr and Almanac interface endpoints
  • Loading branch information
thekashifmalik committed Feb 23, 2021
2 parents a922ba4 + afe257c commit 9d91910
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.8.1

* Fixed bug where built-in interface dict overwrote `interface` methods from Almanac (`interface.search`, `interface.edit`). The `Resource` attribute `interface` is renamed `_interface`.

0.8.0

* Switch to using requests
Expand Down
8 changes: 4 additions & 4 deletions phabricator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ def __repr__(self):
class Resource(object):
def __init__(self, api, interface=None, endpoint=None, method=None, nested=False):
self.api = api
self.interface = interface or copy.deepcopy(parse_interfaces(INTERFACES))
self._interface = interface or copy.deepcopy(parse_interfaces(INTERFACES))
self.endpoint = endpoint
self.method = method
self.nested = nested

def __getattr__(self, attr):
if attr in getattr(self, '__dict__'):
return getattr(self, attr)
interface = self.interface
interface = self._interface
if self.nested:
attr = "%s.%s" % (self.endpoint, attr)
submethod_exists = False
Expand All @@ -254,7 +254,7 @@ def __call__(self, **kwargs):

def _request(self, **kwargs):
# Check for missing variables
resource = self.interface
resource = self._interface

def validate_kwarg(key, target):
# Always allow list
Expand Down Expand Up @@ -391,4 +391,4 @@ def update_interfaces(self):

interfaces = query()

self.interface = parse_interfaces(interfaces)
self._interface = parse_interfaces(interfaces)
2 changes: 1 addition & 1 deletion phabricator/tests/test_phabricator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_map_param_type(self):


def test_endpoint_shadowing(self):
shadowed_endpoints = [e for e in self.api.interface.keys() if e in self.api.__dict__]
shadowed_endpoints = [e for e in self.api._interface.keys() if e in self.api.__dict__]
self.assertEqual(
shadowed_endpoints,
[],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='phabricator',
version='0.8.0',
version='0.8.1',
author='Disqus',
author_email='[email protected]',
url='http://github.com/disqus/python-phabricator',
Expand Down

0 comments on commit 9d91910

Please sign in to comment.