adafruit / Adafruit_CircuitPython_AVRprog

program AVR chips right from CircuitPython!
MIT License
31 stars 20 forks source link

Type annotations and suspected minor bug fix #34

Closed RossK1 closed 6 months ago

RossK1 commented 1 year ago

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.

RossK1 commented 1 year ago

Should be good to resolve #22 . There is a bit of a workaround in the typing of arguments to the builtin "open" method. This should be of type FileDescriptorOrPath from the _typeshed package. This package is in the stdlib, but not in older versions of Python. As such, a type alias for it was defined and used instead. Once circuitpython only supports versions of python that include _typeshed, then it can be switched over as indicated in the code comments.