Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Commit 9505971

Browse files
committed
chore: style black
1 parent fc738d5 commit 9505971

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

gemini/async.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ async def async_init(
107107
"""
108108
self.session = await self._create_async_session()
109109

110-
111-
112-
async def _create_async_session(
113-
self
114-
) -> httpx.AsyncClient:
110+
async def _create_async_session(self) -> httpx.AsyncClient:
115111
"""
116112
Initializes or configures the httpx.AsyncClient session with predefined session headers, proxies, and cookies.
117113
@@ -134,8 +130,8 @@ async def _create_async_session(
134130
headers=HEADERS,
135131
cookies=self.cookies,
136132
timeout=self.timeout,
137-
auto_close=self.auto_close,
138-
close_delay=self.close_delay
133+
auto_close=self.auto_close,
134+
close_delay=self.close_delay,
139135
)
140136

141137
if hasattr(self, "session"):
@@ -144,7 +140,7 @@ async def _create_async_session(
144140
self.running = False
145141

146142
return self.session
147-
143+
148144
def _load_cookies_from_file(self, file_path: str) -> None:
149145
"""Loads cookies from a file and updates the session."""
150146
try:
@@ -216,7 +212,6 @@ def _set_sid_and_nonce(self):
216212
raise ValueError(
217213
"Failed to parse SID or SNlM0e nonce from the response.\nRefresh the Gemini web page or access Gemini in a new incognito browser to resend cookies."
218214
)
219-
220215

221216
except requests.RequestException as e:
222217
raise ConnectionError(f"Request failed: {e}")
@@ -241,7 +236,7 @@ def extract_sid_nonce(response_text):
241236
sid_match = re.search(r'"FdrFJe":"([\d-]+)"', response_text)
242237
nonce_match = re.search(r'"SNlM0e":"(.*?)"', response_text)
243238
return sid_match, nonce_match
244-
239+
245240
def _get_cookies_from_browser(self) -> dict:
246241
"""
247242
Attempts to extract specific Gemini cookies from the cookies stored by web browsers on the current system.
@@ -280,8 +275,6 @@ def _get_cookies_from_browser(self) -> dict:
280275
"Failed to get cookies. Set 'cookies' argument or 'auto_cookies' as True."
281276
)
282277

283-
284-
285278
def _construct_params(self, sid: str) -> str:
286279
"""
287280
Constructs URL-encoded parameters for a request.

gemini/core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ def extract_sid_nonce(response_text):
269269
nonce_match = re.search(r'"SNlM0e":"(.*?)"', response_text)
270270
return sid_match, nonce_match
271271

272-
273272
def _construct_params(self, sid: str) -> str:
274273
"""
275274
Constructs URL-encoded parameters for a request.

0 commit comments

Comments
 (0)