-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
py/repl: Skip private variables when printing tab completion options. #17108
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
py/repl: Skip private variables when printing tab completion options. #17108
Conversation
05a5c7a
to
8c01246
Compare
Code size report:
|
It's actually not easy to make a test for this that is robust because the bug relies on a certain ordering of qstrs in the frozen set of qstrs (it needs qstrs beginning with underscore to appear between the first and last items that match the tab completion). So maybe it's not worth adding a test for? Does the test you added fail prior to the fix in this PR? |
I'll test without the fix again; asyncio did include an This test also highlighted an issue in the original version of this commit in that it was also hiding |
9dceed4
to
ee5694f
Compare
ee5694f
to
4f060bb
Compare
Curiosity - is the code size change different if it's all in one |
ee23d3c
to
bfbb700
Compare
CI needs fixing on this. |
bfbb700
to
e824afd
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17108 +/- ##
=======================================
Coverage 98.56% 98.56%
=======================================
Files 169 169
Lines 21948 21950 +2
=======================================
+ Hits 21633 21636 +3
+ Misses 315 314 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@dpgeorge I've got a working test now I think should be reliable. Added I minor change to the repl test support in run-tests.py to allow using ctrl-keys in these tests, can you think of any negative side effects of this? |
I see it's only used for "special" tests, which limits its scope (that's good!). So probably OK. But, why does it need to run code using paste mode? It seems like it should work just constructing that class normally? |
When the class code it "typed" into repl via pty the auto-indent throws it off. I could flatten the class in the .py file, but then would still need backspace to de-dent in between each function. |
The existing test I'm not against adding an escape sequence parser, but if it's easy to work around that, might be better not to add such complexity? |
I guess we don't have any tests for paste mode, so maybe worth adding that anyway, using escape sequences? |
e5aeb99
to
0153e24
Compare
I've updated / simplified the escape code parser a little in the latest push as suggested earlier.
I had thought that, I went looking and didn't find any. Taking a step back... the test I've added here seems to pass even without the fix in both
|
No, I think what you added here is an improvement, much easier to see what's going on in the test with the escape sequences.
Yes, that would be nice, but not necessary. Only if you have time.
No, it's tricky. It really depends on what qstrs are frozen and the order they appear in. And the test behaviour may change if/when more scripts are frozen. So I think we should just leave this PR as-is. |
0153e24
to
73b3bd1
Compare
CI is failing again... |
73b3bd1
to
f3362c9
Compare
Fixed again; needed dos2unix on the exp files!. |
Thanks for fixing, it looks good now. And thanks for the paste test, that's also looking good! Note: doing tab completion on |
This allows having {\xDD} in tests, which will be expanded to the given hex character. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Any '_' variables/functions in frozen modules are currently printed, when they shouldn't be. That's due to underscore names possibly existing between the start and end qstrs which are used to print the auto-complete matches. The underscore names should be skipped when iterating between the two boundary qstrs. The underscore attributes are removed from the extra coverage exp file because tab completing "import <tab>" no longer lists modules beginning with an underscore. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
f3362c9
to
09541b7
Compare
Summary
The tab completion on repl is intended to not show any attributes starting with a single
_
character, however variables/functions in frozen modules are are currently shown.This PR introduces a change to py/repl to skip private variables when printing tab completion options.
Originally included in #17011
Testing
A unit test has added which covers this, currently based on the asyncio module which is generally frozen in.
However looking again now maybe it would be better to add a suitable function / attribute to
./tests/frozen/frozentest.py
and test against that, assuming it should have the same behavior?