Converted a few class variables into instance variables#284
Converted a few class variables into instance variables#284tleonhardt merged 3 commits intomasterfrom
Conversation
Now that users can nest instances of cmd.Cmd2 to support creating sub-menus, we should need to be more careful about class vs instance variables to prevent potential problems. This converts the following former class variables into instance variables: - multiline_commands - shortcuts - exclude_from_help - exclude_from_history In the process, a couple camelCase variable names got converted to pep8_compliant names. There may be a few other class variables which should be converted to instance variables. But at the very least, this is a good start. This closes #273.
Codecov Report
@@ Coverage Diff @@
## master #284 +/- ##
=======================================
Coverage 91.57% 91.57%
=======================================
Files 1 1
Lines 1424 1424
=======================================
Hits 1304 1304
Misses 120 120
Continue to review full report at Codecov.
|
kotfu
left a comment
There was a problem hiding this comment.
It appears that this would be a breaking change to all subclasses which are using multilineCommands or excludeFromHistory or exclude_from_help or shortcuts. Breaking meaning if I install the soon to be release cmd2 version with these changes, my app won't run anymore until I fix it to use the new variable names. Did I understand the impact of this change correctly?
If so, perhaps we should consider doing something like creating these variable names as properties, so that both the old name and the new name work. That way we can deprecate the old names, but still have them work, to give developers time to modify their code.
|
You make a good point. On second thought, maybe changing the two attribute names isn't such a hot idea. It would even break our own examples. I think the change would be dramatically less breaking if I didn't rename those two. I don't view the act of making these attributes instance members instead of class members to be particularly breaking, especially since I think all of our examples reference them via I think I'll change those back to their original names. Edit: On second thought, I think I am going to roll back the |
…story to prevent breaking change Also: - Reverted multilineCommands and shortcuts to class variables to prevent other breaking changes
Now that users can nest instances of cmd.Cmd2 to support creating sub-menus, we should need to be more careful about class vs instance variables to prevent potential problems.
This converts the following former class variables into instance variables:
In the process, a couple camelCase variable names got converted to pep8_compliant names.
There may be a few other class variables which should be converted to instance variables. But at the very least, this is a good start.