-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-30779: IDLE -- Factor ConfigChanges class from configdialog, put in config; test. #2612
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
@terryjreedy, thanks for your PR! By analyzing the history of the files in this pull request, we identified @csabella, @asvetlov and @kbkaiser to be potential reviewers. |
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.
Some method name need to consider to changed.
Lib/idlelib/config.py
Outdated
configpage.remove_section(section) | ||
configpage.Save() | ||
|
||
|
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.
Please remove one blank line
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.
Done. I appreciate the review. Polishing a patch is really hard.
Lib/idlelib/config.py
Outdated
value -- value for the item. | ||
|
||
Methods | ||
add_item: |
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.
Would you prefer to use add_item
in above changes? Current code is using additem
.
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.
After reviewing configparser parameters, changed to add_option. Will have to change all in test and configdialog and check its tests.
Lib/idlelib/config.py
Outdated
|
||
Methods | ||
add_item: | ||
save_all: Save all the changes to the config file. |
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.
Need to add set_value
document (will dev use this method alone?)
Lib/idlelib/config.py
Outdated
page[section][item] = value | ||
|
||
@staticmethod | ||
def set_value(config_type, section, item, value): |
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.
How about using save_item
for consistency?
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.
save_option for consistency with add_option and save_all ;-). Only called in save_all,and twice in tests.
for config_type in ['keys', 'highlight']: | ||
# Save these even if unchanged! | ||
idleConf.userCfg[config_type].Save() | ||
self.clear() |
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.
Should the result be clear after save_all
?
If should, then the docstring need to note it.
But I think it should not clear after save_all
, this should let dev to do when needed
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, it should be clear after save_all
, that mean the changed has been apply. Maybe this side-affect need to be documented.
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 our current standard, yes. Changed.
@@ -44,7 +40,7 @@ def setUpModule(): | |||
|
|||
def tearDownModule(): | |||
global root, configure | |||
idleConf.userCfg = testcfg | |||
idleConf.userCfg = usercfg |
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.
I think you should rebase/merge master
branch since this changed has been merged into via PR #2606.
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.
I though maybe I branched after fetching that. Anyway, I fetched again, pushed master to origin, and
ran <git merge origin/master>, from the devguide, which has worked before. and pushed.
... Above -+ is gone from new diff.
Lib/idlelib/config.py
Outdated
def __init__(self): | ||
"Create a page for each configuration file" | ||
self.pages = [] # List of unhashable dicts. | ||
for config_type in ('main', 'highlight', 'keys', 'extensions'): |
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.
Question on the tuple ('main', 'highlight', 'keys', 'extensions')
This is in the IdleConf.__init__
:
self.config_types = ('main', 'extensions', 'highlight', 'keys')
Any benefit to making that a module constant?
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.
I left it as idleConf attribute and used the attribute here to eliminate the duplication. Good catch.
Lib/idlelib/configdialog.py
Outdated
if section not in self.changed_items[typ]: | ||
self.changed_items[typ][section] = {} | ||
self.changed_items[typ][section][item] = value | ||
changes.add_option('main', 'EditorWindow', 'encoding', value) | ||
|
||
def GetDefaultItems(self): |
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.
I can't find GetDefaultItems used anywhere. Should it be removed?
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.
I grepped the file for 'default' to make sure you had not changed the name elsewhere to somethingdefaultsomething. 55 hit, not orphan function call. My guess is that someone wrote this, possibly for the check in save_option, and someone (same or other) decided to stick with idleConf instead of the skeletal duplicate, but did not remove.
I removed it in a separate commit.
|
||
def add_option(self, config_type, section, item, value): | ||
"Add item/value pair for config_type and section." | ||
page = self[config_type] |
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.
I didn't know if we needed to add a check for config_type to make sure it's valid before accessing it.
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.
What would add_option do if it did? It expects new sections. New config-types are a bug. A test of the user, config dialog, should fail. General principle: only check first or catch after if one has an alternative action in mind that is better than letting an exception bubble up.
|
||
def test_clear(self): | ||
changes = self.load() | ||
changes.clear() |
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.
Test_add_option verifies that load loads something. I added a comment to def load...
…, put in config; test. (pythonGH-2612) * In config, put dump test code in a function; run it and unittest in 'if __name__ == '__main__'. * Add class config.ConfigChanges based on changes_class_v4.py on bpo issue. * Add class test_config.ChangesTest, partly based on configdialog_tests_v1.py on bpo issue. * Revise configdialog to use ConfigChanges, mostly as specified in tracker msg297804. * Revise test_configdialog to match configdialog changes. All tests pass in both files. * Remove configdialog functions unused or moved to ConfigChanges. Cheryl Sabella contributed parts of the patch. (cherry picked from commit 349abd9)
…, put in config; test. (GH-2612) (#2625) * In config, put dump test code in a function; run it and unittest in 'if __name__ == '__main__'. * Add class config.ConfigChanges based on changes_class_v4.py on bpo issue. * Add class test_config.ChangesTest, partly based on configdialog_tests_v1.py on bpo issue. * Revise configdialog to use ConfigChanges, mostly as specified in tracker msg297804. * Revise test_configdialog to match configdialog changes. All tests pass in both files. * Remove configdialog functions unused or moved to ConfigChanges. Cheryl Sabella contributed parts of the patch. (cherry picked from commit 349abd9)
No description provided.