GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — gh-148823: Avoid importing `_colorize` when creating an `ArgumentParser` by DavidCEllis · Pull Request #148827 · python/cpython Conversation
|
|
Ah this pinged more people than I had anticipated. This appears to be due to the modification to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.LAZY_IMPORTS, | ||
| ) | ||
|
|
||
| def test_create_parser(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is it worth also checking .parse_args()? I think a good outcome is we only import colorize in the uncommon case where there's a parsing error or we invoke --help.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, it probably is. I'll add one. I'm fairly sure I at least tried this...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Documentation build overview
97 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This mostly looks good and I'd like to get it into 3.15, but tests are failing, we're actually still importing _colorize in one of the paths.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, locally on this branch I'm not though which is a little confusing... All of the lazy import tests are now failing. I assume I'll have to handle the merge conflicts to figure out what's going on? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Inline comments seem to disappear, but wanted to add that it would be nice to make it so parsing args doesn't trigger the lazy import of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I feel ideally we should avoid instantiating the HelpFormatter at all but haven't looked into how hard that is. Having to inline |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah, it's #149375 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I generally agree on avoiding the HelpFormatter, there seems to be a lot of logic that gets formatted fairly early though. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks great!
The only thing that we may want to consider is that since _colorize is private and _ColorlessTheme exists as an unenforced parallel implementation of ThemeSection.no_colors(), it may be worth adding a small test that imports _colorize, grabs get_theme(force_no_color=True).argparse, iterates its fields, and asserts each is ""?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That's fine, I can do that. I'm just trying to work out how to stop the import from being triggered due to the changes from #149375 Right now when any argument is added the help check now calls |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I cannot believe I have to comment via screenshot but inline comments don't work so... I think this should be safe to do since it's read only anyway? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yes! That's what I was looking for. I had got around to turning it off just for Edit: Now how do I accept a change from a screenshot 😆 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
GitHub employees, if you're listening, I have a Copilot feature request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.