Skip to content

Commit

Permalink
chore: Remove unnecessary else after guard condition (#602)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #602

Reviewed By: mengxuanzhangz

Differential Revision: D49887267

Pulled By: stcheng

fbshipit-source-id: 033619e69f7da1ddc4ef9bc5a59a4d879ebee724
  • Loading branch information
yezz123 authored and facebook-github-bot committed Oct 4, 2023
1 parent 7511fe3 commit a85a1bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
4 changes: 1 addition & 3 deletions facebook_business/adobjects/helpers/adaccountmixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def get_my_account(cls, api=None):
me = AdAccountUser(fbid='me', api=api)

# Get first account connected to the user
my_account = me.edge_object(cls)

return my_account
return me.edge_object(cls)

def opt_out_user_from_targeting(self,
schema,
Expand Down
40 changes: 19 additions & 21 deletions facebook_business/adobjects/helpers/adimagemixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ class AdImageMixin:
@classmethod
def remote_create_from_zip(cls, filename, parent_id, api=None):
api = api or FacebookAdsApi.get_default_api()
open_file = open(filename, 'rb')
response = api.call(
'POST',
(parent_id, cls.get_endpoint()),
files={filename: open_file},
)
open_file.close()

with open(filename, 'rb') as open_file:
response = api.call(
'POST',
(parent_id, cls.get_endpoint()),
files={filename: open_file},
)
data = response.json()

objs = []
Expand Down Expand Up @@ -73,23 +71,23 @@ def _set_data(self, data):
}
"""

if 'images' in data:
_, data = data['images'].popitem()
if 'images' not in data:
return AbstractCrudObject._set_data(self, data)

for key in map(str, data):
self._data[key] = data[key]
_, data = data['images'].popitem()

# clear history due to the update
self._changes.pop(key, None)
for key in map(str, data):
self._data[key] = data[key]

self._data[self.Field.id] = '%s:%s' % (
self.get_parent_id_assured()[4:],
self[self.Field.hash],
)
# clear history due to the update
self._changes.pop(key, None)

return self
else:
return AbstractCrudObject._set_data(self, data)
self._data[self.Field.id] = '%s:%s' % (
self.get_parent_id_assured()[4:],
self[self.Field.hash],
)

return self

def remote_create(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def reserve(
self.Field.action: self.Action.reserve,
}
# Filter out None values.
params = dict((k, v) for k, v in params.items() if v is not None)
params = {k: v for k, v in params.items() if v is not None}

response = self.get_api_assured().call(
'POST',
Expand Down
3 changes: 1 addition & 2 deletions facebook_business/adobjects/serverside/event_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,9 @@ def execute(self):
fields=[],
params=params,
)
event_response = EventResponse(events_received=response['events_received'],
return EventResponse(events_received=response['events_received'],
fbtrace_id=response['fbtrace_id'],
messages=response['messages'])
return event_response

def execute_with_client(self, params):
url = '/'.join([
Expand Down

0 comments on commit a85a1bd

Please sign in to comment.