Skip to content

Commit edef59a

Browse files
committed
merge main, resolve conflicts
1 parent c97cc4b commit edef59a

26 files changed

+162
-134
lines changed

adafruit_requests.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ def _read_from_buffer(
191191

192192
def _readinto(self, buf: bytearray) -> int:
193193
if not self.socket:
194-
raise RuntimeError(
195-
"Newer Response closed this one. Use Responses immediately."
196-
)
194+
raise RuntimeError("Newer Response closed this one. Use Responses immediately.")
197195

198196
if not self._remaining:
199197
# Consume the chunk header if need be.
@@ -280,10 +278,7 @@ def _parse_headers(self) -> None:
280278

281279
def _validate_not_gzip(self) -> None:
282280
"""gzip encoding is not supported. Raise an exception if found."""
283-
if (
284-
"content-encoding" in self.headers
285-
and self.headers["content-encoding"] == "gzip"
286-
):
281+
if "content-encoding" in self.headers and self.headers["content-encoding"] == "gzip":
287282
raise ValueError(
288283
"Content-encoding is gzip, data cannot be accessed as json or text. "
289284
"Use content property to access raw bytes."
@@ -394,9 +389,7 @@ def _build_boundary_data(self, files: dict): # pylint: disable=too-many-locals
394389
if len(field_values) >= 4:
395390
file_headers = field_values[3]
396391
for file_header_key, file_header_value in file_headers.items():
397-
boundary_objects.append(
398-
f"{file_header_key}: {file_header_value}\r\n"
399-
)
392+
boundary_objects.append(f"{file_header_key}: {file_header_value}\r\n")
400393
boundary_objects.append("\r\n")
401394

402395
if hasattr(file_handle, "read"):
@@ -500,7 +493,8 @@ def _send_header(self, socket, header, value):
500493
self._send_as_bytes(socket, value)
501494
self._send(socket, b"\r\n")
502495

503-
def _send_request( # noqa: PLR0913 Too many arguments in function definition
496+
# noqa: PLR0912 Too many branches
497+
def _send_request( # noqa: PLR0913,PLR0912 Too many arguments in function definition,Too many branches
504498
self,
505499
socket: SocketType,
506500
host: str,
@@ -543,9 +537,7 @@ def _send_request( # noqa: PLR0913 Too many arguments in function definition
543537
data_is_file = False
544538
boundary_objects = None
545539
if files and isinstance(files, dict):
546-
boundary_string, content_length, boundary_objects = (
547-
self._build_boundary_data(files)
548-
)
540+
boundary_string, content_length, boundary_objects = self._build_boundary_data(files)
549541
content_type_header = f"multipart/form-data; boundary={boundary_string}"
550542
elif data and hasattr(data, "read"):
551543
data_is_file = True
@@ -644,9 +636,7 @@ def request( # noqa: PLR0912,PLR0913,PLR0915 Too many branches,Too many argumen
644636
)
645637
ok = True
646638
try:
647-
self._send_request(
648-
socket, host, method, path, headers, data, json, files
649-
)
639+
self._send_request(socket, host, method, path, headers, data, json, files)
650640
except OSError as exc:
651641
last_exc = exc
652642
ok = False

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@
4646
creation_year = "2019"
4747
current_year = str(datetime.datetime.now().year)
4848
year_duration = (
49-
current_year
50-
if current_year == creation_year
51-
else creation_year + " - " + current_year
49+
current_year if current_year == creation_year else creation_year + " - " + current_year
5250
)
5351
copyright = year_duration + " ladyada"
5452
author = "ladyada"

examples/wifi/expanded/requests_wifi_api_discord.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def time_calc(input_time):
6969
DEBUG_RESPONSE = False
7070

7171
try:
72-
with requests.get(
73-
url=DISCORD_SOURCE, headers=DISCORD_HEADER
74-
) as discord_response:
72+
with requests.get(url=DISCORD_SOURCE, headers=DISCORD_HEADER) as discord_response:
7573
discord_json = discord_response.json()
7674
except ConnectionError as e:
7775
print(f"Connection Error: {e}")

examples/wifi/expanded/requests_wifi_api_fitbit.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
3131
Fitbit_ClientID = os.getenv("FITBIT_CLIENTID")
3232
Fitbit_Token = os.getenv("FITBIT_ACCESS_TOKEN")
33-
Fitbit_First_Refresh_Token = os.getenv(
34-
"FITBIT_FIRST_REFRESH_TOKEN"
35-
) # overides nvm first run only
33+
Fitbit_First_Refresh_Token = os.getenv("FITBIT_FIRST_REFRESH_TOKEN") # overides nvm first run only
3634
Fitbit_UserID = os.getenv("FITBIT_USERID")
3735

3836
# Set debug to True for full INTRADAY JSON response.
@@ -167,8 +165,7 @@ def time_calc(input_time):
167165
print(" | Requesting authorization for next token")
168166
if DEBUG:
169167
print(
170-
"FULL REFRESH TOKEN POST:"
171-
+ f"{FITBIT_OAUTH_TOKEN}{FITBIT_OAUTH_REFRESH_TOKEN}"
168+
"FULL REFRESH TOKEN POST:" + f"{FITBIT_OAUTH_TOKEN}{FITBIT_OAUTH_REFRESH_TOKEN}"
172169
)
173170
print(f"Current Refresh Token: {Refresh_Token}")
174171
# TOKEN REFRESH POST
@@ -270,24 +267,20 @@ def time_calc(input_time):
270267
try:
271268
# Fitbit's sync to mobile device & server every 15 minutes in chunks.
272269
# Pointless to poll their API faster than 15 minute intervals.
273-
activities_heart_value = fitbit_json["activities-heart-intraday"][
274-
"dataset"
275-
]
270+
activities_heart_value = fitbit_json["activities-heart-intraday"]["dataset"]
276271
if MIDNIGHT_DEBUG:
277272
RESPONSE_LENGTH = 0
278273
else:
279274
RESPONSE_LENGTH = len(activities_heart_value)
280275
if RESPONSE_LENGTH >= 15:
281-
activities_timestamp = fitbit_json["activities-heart"][0][
282-
"dateTime"
283-
]
276+
activities_timestamp = fitbit_json["activities-heart"][0]["dateTime"]
284277
print(f" | | Fitbit Date: {activities_timestamp}")
285278
if MIDNIGHT_DEBUG:
286279
ACTIVITIES_LATEST_HEART_TIME = "00:05:00"
287280
else:
288-
ACTIVITIES_LATEST_HEART_TIME = fitbit_json[
289-
"activities-heart-intraday"
290-
]["dataset"][RESPONSE_LENGTH - 1]["time"]
281+
ACTIVITIES_LATEST_HEART_TIME = fitbit_json["activities-heart-intraday"][
282+
"dataset"
283+
][RESPONSE_LENGTH - 1]["time"]
291284
print(f" | | Fitbit Time: {ACTIVITIES_LATEST_HEART_TIME[0:-3]}")
292285
print(f" | | Today's Logged Pulses: {RESPONSE_LENGTH}")
293286

examples/wifi/expanded/requests_wifi_api_github.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def time_calc(input_time):
6161
try:
6262
print(" | Attempting to GET Github JSON!")
6363
try:
64-
with requests.get(
65-
url=GITHUB_SOURCE, headers=GITHUB_HEADER
66-
) as github_response:
64+
with requests.get(url=GITHUB_SOURCE, headers=GITHUB_HEADER) as github_response:
6765
github_json = github_response.json()
6866
except ConnectionError as e:
6967
print("Connection Error:", e)

examples/wifi/expanded/requests_wifi_api_mastodon.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ def time_calc(input_time):
4848

4949
# Publicly available data no header required
5050
MAST_SOURCE = (
51-
"https://"
52-
+ MASTODON_SERVER
53-
+ "/api/v1/accounts/"
54-
+ MASTODON_USERID
55-
+ "/statuses?limit=1"
51+
"https://" + MASTODON_SERVER + "/api/v1/accounts/" + MASTODON_USERID + "/statuses?limit=1"
5652
)
5753

5854
while True:

examples/wifi/expanded/requests_wifi_api_openskynetwork_private.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ def time_calc(input_time):
6969

7070

7171
def _format_datetime(datetime):
72-
return f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year} {datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
72+
return (
73+
f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year} "
74+
f"{datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
75+
)
7376

7477

7578
while True:
@@ -87,9 +90,7 @@ def _format_datetime(datetime):
8790
print(" | Attempting to GET OpenSky-Network Single Private Flight JSON!")
8891
print(" | Website Credentials Required! Allows more daily calls than Public.")
8992
try:
90-
with requests.get(
91-
url=OPENSKY_SOURCE, headers=OPENSKY_HEADER
92-
) as opensky_response:
93+
with requests.get(url=OPENSKY_SOURCE, headers=OPENSKY_HEADER) as opensky_response:
9394
opensky_json = opensky_response.json()
9495
except ConnectionError as e:
9596
print("Connection Error:", e)

examples/wifi/expanded/requests_wifi_api_openskynetwork_private_area.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ def time_calc(input_time):
8383

8484

8585
def _format_datetime(datetime):
86-
return f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year} {datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
86+
return (
87+
f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year} "
88+
f"{datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
89+
)
8790

8891

8992
while True:
@@ -100,9 +103,7 @@ def _format_datetime(datetime):
100103
try:
101104
print(" | Attempting to GET OpenSky-Network Area Flights JSON!")
102105
try:
103-
with requests.get(
104-
url=OPENSKY_SOURCE, headers=OSN_HEADER
105-
) as opensky_response:
106+
with requests.get(url=OPENSKY_SOURCE, headers=OSN_HEADER) as opensky_response:
106107
opensky_json = opensky_response.json()
107108
except ConnectionError as e:
108109
print("Connection Error:", e)

examples/wifi/expanded/requests_wifi_api_openskynetwork_public.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def time_calc(input_time):
5454

5555

5656
def _format_datetime(datetime):
57-
return f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year} {datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
57+
return (
58+
f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year} "
59+
f"{datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
60+
)
5861

5962

6063
while True:

examples/wifi/expanded/requests_wifi_api_twitch.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ def _format_datetime(datetime):
129129
"Client-Id": "" + TWITCH_CID + "",
130130
}
131131
TWITCH_FOLLOWERS_SOURCE = (
132-
"https://api.twitch.tv/helix/channels"
133-
+ "/followers?"
134-
+ "broadcaster_id="
135-
+ TWITCH_UID
132+
"https://api.twitch.tv/helix/channels" + "/followers?" + "broadcaster_id=" + TWITCH_UID
136133
)
137134
print(" | Attempting to GET Twitch JSON!")
138135
try:

0 commit comments

Comments
 (0)