Skip to content

Commit

Permalink
deepsource fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonDane committed Apr 10, 2024
1 parent 351a5d7 commit ae1e292
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fennel_invest_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fennel_invest_api.endpoints import Endpoints
from fennel_invest_api.fennel import Fennel

__all__ = ["Endpoints", "Fennel"]
__all__ = ["Endpoints", "Fennel"]
4 changes: 3 additions & 1 deletion fennel_invest_api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def retrieve_bearer_url(self):
def oauth_url(self):
return f"{self.accounts}/oauth/token"

def build_graphql_payload(self, query, variables={}):
def build_graphql_payload(self, query, variables=None):
if variables is None:
variables = {}
return {
"operationName": None,
"variables": variables,
Expand Down
10 changes: 4 additions & 6 deletions fennel_invest_api/fennel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def login(self, email, wait_for_code=True, code=None):
if self.Bearer is not None:
if self._verify_login():
return True
else:
self._clear_credentials()
self._clear_credentials()
if code is None:
url = self.endpoints.retrieve_bearer_url()
payload = {
Expand Down Expand Up @@ -103,7 +102,6 @@ def login(self, email, wait_for_code=True, code=None):
self.Bearer = response['access_token']
self.Refresh = response['refresh_token']
self.ID_Token = response['id_token']
# refresh_token() # Refresh token after login?
self._save_credentials()
return True

Expand All @@ -129,12 +127,12 @@ def _verify_login(self):
try:
self.get_portfolio_summary()
return True
except Exception as e:
except Exception:
self.refresh_token()
try:
self.get_portfolio_summary()
return True
except Exception as e:
except Exception:
return False

@check_login
Expand Down Expand Up @@ -186,4 +184,4 @@ def place_order(self, ticker, quantity, side, price="market"):
order_response = self.session.post(self.endpoints.graphql, headers=headers, data=query)
if order_response.status_code != 200:
raise Exception(f"Order Request failed with status code {order_response.status_code}: {order_response.text}")
return order_response.json()
return order_response.json()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
author="Nelson Dane",
packages=["fennel_invest_api"],
install_requires=["requests", "python-dotenv"],
)
)

0 comments on commit ae1e292

Please sign in to comment.