-
Notifications
You must be signed in to change notification settings - Fork 1
tests/extmod/typing_*: Updates to multiple typing tests. #8
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
base: builtintypingmodule
Are you sure you want to change the base?
Conversation
Signed-off-by: stijn <[email protected]>
Signed-off-by: Jos Verlinde <[email protected]>
Signed-off-by: Jos Verlinde <[email protected]>
These are constructs used in static typing that are different between MicroPython and CPython, and should be documented as such. Signed-off-by: Jos Verlinde <[email protected]>
PEP 484 Type Hints Python 3.5 PEP 526 Syntax for Variable Annotations Python 3.6 PEP 544 Protocols: Structural subtyping (static duck typing) Python 3.8 PEP 560 Core support for typing module and generic types Python 3.7 PEP 586 Literal Types Python 3.8 PEP 589 TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys Python 3.8 PEP 591 Adding a final qualifier to typing Python 3.8 Signed-off-by: Jos Verlinde <[email protected]>
Signed-off-by: Jos Verlinde <[email protected]>
…in typing alias specifications. Signed-off-by: Jos Verlinde <[email protected]>
PEP 484 Type Hints Python 3.5 PEP 526 Syntax for Variable Annotations Python 3.6 PEP 544 Protocols: Structural subtyping (static duck typing) Python 3.8 PEP 560 Core support for typing module and generic types Python 3.7 PEP 586 Literal Types Python 3.8 PEP 589 TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys Python 3.8 PEP 591 Adding a final qualifier to typing Python 3.8 Signed-off-by: Jos Verlinde <[email protected]>
Signed-off-by: Jos Verlinde <[email protected]>
…in typing alias specifications. Signed-off-by: Jos Verlinde <[email protected]>
Signed-off-by: Jos Verlinde <[email protected]>
Signed-off-by: Jos Verlinde <[email protected]>
|
Thanks! There are a bunch of tests which are now commented out like but that is actually rather simple to support in the C typing module. Probably not so in the Python typing module. Likewise commenting the 'Verify assignment is not possible' test in typing_syntax.py hides that the C typing module supports this and by doing so is compatible with CPython ( So I'm thinking now that (apart from actual syntax errors which make it impossible to run a file) it's probably better if no tests are commented out in order to get a more complete list of what works and what doesn't? Though by that reasoning there also shouldn't be cpydiff tests yet (again, apart from syntax errors). |
|
We can use these test to explore what is possible at what costs. It would be very interesting to explore if the index notation for user defined Genetics can be supported, but I think that may be a large chunk of work and perhaps best kept for a seperate PR. |
To be clear, you mean the code sample I posted i.e. support This is only POC where I'm exploring some options, didn't test if there are adverse effects, but it does pass those commented out tests and fixes some of the FIXMEs. |
|
IIUC we need a runtime implementations of metaclass, class_getitem, and mro_entries. See :
because I have not been able to get it to work at all in just .py , im also unaware of the things that might break if the runtime behavior of the 'minimal stub' is. so perhaps we can have something that is stable enough to merge for 1.27.0 A rebase would go well with that as well - ( my attempts at that failed beyond recovery) |
c99a336 to
01085c8
Compare
Hmm, right. This is a rather severe issue. And my POC exhibits similar breaking behavior: it results in not being to instantiate TestClass. Note the following snippet also prints None when used with micropython/micropython-lib#1051 (it does happen to work correctly in my current branch with the C typing module after I've been messing around with allowing multiple inheritance but only if all inherited classes come from the typing module): So just like the one issue with the decorator I found in my original PR, it seems to come down to using typing for anything but annotating (i.e.
I'm not sure if we can risk merging any implementation using __Ignore unless we have even more test coverage. Well, and a way to fix that which indeed is going to require some runtime support.
I did actually rebase everything I have on master (minus your 'extmod/modtyping: Add support for tytping aliases and typing.Literal in typing alias specifications.' commit because I was exploring other ways to do that); I'll push that already. |
|
Ill take a look at the latest, must have missed or mixed up my remotes. Perhaps we should move the discussion to the PR to make sure that Damien is aware. |
Based on the recent discussion I updated the tests
With these tests I have compared the .c and the .py implementation on CPython/PEP conformance and code size.
See : micropython/micropython-lib#1051