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: facebook/facebook-python-business-sdk#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 7476dfa commit c2a2f74
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
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
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

0 comments on commit c2a2f74

Please sign in to comment.