-
Notifications
You must be signed in to change notification settings - Fork 257
Fixes #220 for platforms that do not support typing #222
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
@Neradoc if you are able, can you check this out and let me know if this works for you? I tested this out myself using MicroPython 1.18 and I don't see any import errors, but it would be good to get someone else to test it out. |
can ya rebase plz :) |
@ladyada sorry, can you clarify what you'd like me to rebase this off of? (it's currently rebased off main) |
Also, I'm not quite sure what to do about the failing CI check:
AFAIK, MicroPython doesn't support the
So I tried wrapping it in a try/except block:
This seems to work fine for MicroPython in my initial tests, but also seems to be discouraged in PEP-236:
Any suggestions for how to fix this? |
adafruit_platformdetect/chip.py
Outdated
import os | ||
import sys | ||
from typing import Optional, TYPE_CHECKING | ||
|
||
# from tokenize import Name |
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.
MicroPython doesn't support the tokenize
module, so I had to comment it out to get this working. It appears to be an unused import and can probably be removed, but I wanted to double check that I didn't miss something.
Tested in Micropython, it allows importing the blinka modules.
Note that this is an error in C Python in general, not just the docs CI.
It is possible to use instead a parent "protocol" class for Detector for the typing annotation in a common file and completely drop the |
Note that any general-purpose annotation types, protocols, etc. should now be added to https://github.com/adafruit/Adafruit_CircuitPython_Typing. I see what you're adding is specific to Blinka: those I would not expect to see in https://github.com/adafruit/Adafruit_CircuitPython_Typing. |
@Neradoc I'm not totally sure I understood what you were proposing, but I pushed up some changes that I think do what you suggested. (This is my first time doing anything with python typing, so let me know if I'm doing something totally wacky.) BTW, it looks like |
__version__ = "0.0.0-auto.0" | ||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PlatformDetect.git" |
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.
@dhalbert or @makermelissa can you give me some context as to why these lines are included in __init__.py
, board.py
, and chip.py
(vs. just having it in __init__.py
)? Just wondering if these should be added to any new files I add (like protocols.py
that I added in this draft)
You can use |
Closing in favor of #230, which fixed the error. |
This addresses the issue reported in #220 where the typing module is not supported on MicroPython.