-
Notifications
You must be signed in to change notification settings - Fork 19
Type annotations and suspected minor bug fix #34
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
Conversation
… open operation rather than a field in file_state dictionary
Should be good to resolve #22 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the submission, super awesome! Feedback below!
adafruit_avrprog.py
Outdated
with open(file_name, "r") as file_state[ # pylint: disable=unspecified-encoding | ||
"f" | ||
]: | ||
file_state = {"line": 0, "ext_addr": 0, "eof": False, "f": TextIOWrapper} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's going to get replaced, you could just make the "f"
key equal to None
and not import TextIOWrapper
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did move FileState into a TypedDict and change the initial value to None. But also kept TextIOWrapper imported and set the type of f
in the TypedDict to Optional[TextIOWrapper]
so that it shows the possible values of None or an open file.
If there is a better way to do that we can make further changes in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me at this point.
I pushed a few commits that make changes based on the prior review feedback.
I tested this branch successfully on a Feather RP2040 using the avrprog_program_uno328.py
example script. It ran and seems to have successfully loaded the optiboot file.
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 8.1.1 from 8.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#201 from adafruit/connect_dgram_mode Updating https://github.com/adafruit/Adafruit_CircuitPython_ILI9341 to 1.5.0 from 1.4.2: > Merge pull request adafruit/Adafruit_CircuitPython_ILI9341#38 from RetiredWizard/main Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3MDL to 1.2.0 from 1.1.27: > Merge pull request adafruit/Adafruit_CircuitPython_LIS3MDL#26 from ContosChaos/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_AVRprog to 1.5.1 from 1.5.0: > Merge pull request adafruit/Adafruit_CircuitPython_AVRprog#34 from RossK1/main Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Mostly addition of type annotations, but one commit to fix a suspected bug.
The open function was trying to add an attribute to the file_name variable. This variable was also later never used. Above in the code, the same pattern is used to set the variable on the file_state dictionary instead, which is used. So I presume this was the intended code here too.