Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with in examples, remove close in json() #188

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

justmobilize
Copy link
Collaborator

@justmobilize justmobilize commented Apr 20, 2024

Update the examples to use with request.method as response: and removed the close in the Response.json() as it doesn't match CPython

Tested the wifi standard and advanced and the rocketlive in advanced

fixes #186

@@ -321,7 +321,7 @@ def json(self) -> Any:
obj = json_module.load(self._raw)
if not self._cached:
self._cached = obj
self.close()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the .close() here, as it's not standard in CPython

try:
fitbit_json = fitbit_get_response.json()
with requests.get(url=FBIS, headers=FBH) as fitbit_get_response:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few of these, I moved the initial connection into the try/except block

Comment on lines -95 to -96
github_response.close()
print("✂️ Disconnected from Github API")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed these closes, and the disconnected message

@justmobilize justmobilize marked this pull request as ready for review April 20, 2024 21:47
@DJDevon3
Copy link
Contributor

Wow, thank you. Saved me from all these changes. 🙏

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for working through all of those!

I tested a handful of them on a Feather S3 TFT and the ESP32SPI ones on a PyPortal Titano

@FoamyGuy FoamyGuy merged commit e433597 into adafruit:main Apr 27, 2024
1 check passed
@justmobilize justmobilize deleted the with-updates branch April 27, 2024 16:52
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 28, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 6.0.0 from 5.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#150 from pinkavaj/pi-fix-sock-exit
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#160 from justmobilize/remove-wsgiserver

Updating https://github.com/adafruit/Adafruit_CircuitPython_ConnectionManager to 1.2.0 from 1.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ConnectionManager#13 from justmobilize/close-all-and-counts

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 3.2.6 from 3.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#188 from justmobilize/with-updates

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please re-write examples to use with ... as request: style
3 participants