-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
TypedDict completions: tests added #1495
Conversation
Given 87161df, values(from_instance=False) doesn't produce completions anymore. Therefore, we remove from_instance as an argument.
Adds a function that takes the TypedDict as an argument. Note: the last two tests are failing, along with lots of other tests throughout the system.
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.
The completion on line 561 is actually right. The test is wrong. You should just change it to 'foo
. Note that the ending quote is already there, therefore it's not needed anymore. This might look a bit strange, but it makes sense if you look at other dict completion stuff.
That's obviously my fault. So the code seems to be in a good shape and the tests should all be passing after these small changes. I think the last thing we should do is make an inheritance example.
test/completion/pep0484_typing.py
Outdated
|
||
#? str() | ||
a_string | ||
#? [float()] |
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 line is wrong syntax, you should write #? float()
instead of #? [float()]
. For multiple results you could just write #? float() str()
. It's separated by spaces.
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.
By [float()]
, I mean a "list of floats". I don't know how many floats will be present in the result. If [float()]
is the wrong syntax, how would I express an expected "list of floats"?
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.
It's not really possible to test this AFAIK with just one test. We could obviously make the test algorithm a bit smarter. However I usually test stuff like this with:
#? list()
a_list_of_strings
#? float()
a_list_of_strings[undefined_index]
BTW: I think you mean a_list_of_floats
, so the name is wrong :)
Regarding changing the test to |
Regarding |
Note: tests currently failing
Sadly, looks like integration tests are failing with inheritance. Here are the relevant test failures; hopefully you're able to see where and why things are going weirdly.
|
#? str() | ||
foo | ||
#? int() | ||
an_int |
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.
foo
and an_int
should be #?
. They don't infer anything, this is not a bug, Python would pretty much say the same thing.
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.
Ah, I see. I've changed the check for an_int
to #?
and removed the check for foo
(it's apparently a function we've defined for other tests, so it has a weird type that's tied to other tests and I think it's prudent to avoid testing for that).
Note: foo is defined as a function a the module level so I remove it from consideration here to avoid complicating this test with other tests in the module.
I'll look into it. |
Merged to master in bb91b96 Fixed the issues in 6097373. The issue was actually that the mro doesn't work anymore if the class is already not a class anymore. I realized that we could just do this when an instance of the TypedDict would be created. For now this works great. Thanks again for your work on this one! |
Continues the conversation in this issue: #1478
Note: many tests are failing at present, but not the ones I've added. Notably, one of the tests for actually completing TypedDict keyword parameters that includes quotes is failing weirdly. This tells me there may be an improperly-handled edge case for key completion somewhere. @davidhalter do you have any ideas about where this could be coming from?