Check if name is in self.get_names() before removing#272
Merged
tleonhardt merged 1 commit intopython-cmd2:masterfrom Feb 12, 2018
Merged
Check if name is in self.get_names() before removing#272tleonhardt merged 1 commit intopython-cmd2:masterfrom
tleonhardt merged 1 commit intopython-cmd2:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #272 +/- ##
==========================================
+ Coverage 91.56% 91.56% +<.01%
==========================================
Files 1 1
Lines 1422 1423 +1
==========================================
+ Hits 1302 1303 +1
Misses 120 120
Continue to review full report at Codecov.
|
tleonhardt
approved these changes
Feb 12, 2018
| # Remove any command names which are explicitly excluded from the help menu | ||
| for name in self.exclude_from_help: | ||
| names.remove(name) | ||
| if name in names: |
Member
There was a problem hiding this comment.
Nice ruggedization. Thanks for the PR!
Member
|
I agree, exclude_from_help should probably be an instance variable. Now that we are nesting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to avoid hitting
ERROR: Invalid syntax: list.remove(x): x not in listif a command is added to exclude_from_help which does not exist in the instance.I ran into this when trying to use 2 nested prompts each with different exclude_from_help lists. Once the second prompt was instantiated, the 'help' command is updated at the class level, so the command list may now be inaccurate for other instances.
Perhaps it should be considered to change exclude_from_help to an instance variable.