shtab icon indicating copy to clipboard operation
shtab copied to clipboard

add `default_complete` option

Open casperdcl opened this issue 3 years ago • 3 comments

Fixes #65 /CC @tshu-w

casperdcl avatar Jun 21 '22 16:06 casperdcl

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.11%.

Quality metrics Before After Change
Complexity 41.79 ⛔ 42.09 ⛔ 0.30 👎
Method Length 110.09 🙂 112.03 🙂 1.94 👎
Working memory 18.29 ⛔ 18.28 ⛔ -0.01 👍
Quality 29.55% 😞 29.44% 😞 -0.11% 👎
Other metrics Before After Change
Lines 1055 1068 13
Changed files Quality Before Quality After Quality Change
shtab/init.py 29.55% 😞 29.44% 😞 -0.11% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
shtab/init.py get_bash_commands 78 ⛔ 506 ⛔ 26 ⛔ 2.72% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
shtab/init.py complete_zsh 62 ⛔ 754 ⛔ 25 ⛔ 3.53% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
shtab/init.py get_bash_commands.recurse 58 ⛔ 452 ⛔ 26 ⛔ 4.43% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
shtab/init.py complete_tcsh 57 ⛔ 403 ⛔ 19 ⛔ 8.18% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
shtab/init.py complete_zsh.recurse 18 🙂 214 ⛔ 16 ⛔ 31.98% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

sourcery-ai[bot] avatar Jun 21 '22 16:06 sourcery-ai[bot]

@casperdcl Hi, I try this commit but it doesn't work on my side. Steps:

  1. install shtab
pip install git+https://github.com/iterative/shtab.git@default_complete
  1. change code to use DEFAULT_FUNCTIONS:
shtab.add_argument_to(self.parser, ["-s", "--print-completion"], default_complete=DEFAULT_FUNCTIONS)
  1. generate completion script:
run -s zsh

However, the script doesn't contains _default either.

……
_shtab_run_tune_options=(
  "(- :)"{-h,--help}"[show this help message and exit]"
  {-c,--config}"[Path to a configuration file in json or yaml format.]:config:"
  "--print_config[Print the configuration after applying all other arguments and exit.]:print_config:"
  "--seed_everything[Set to an int to run seed_everything with this value before classes instantiation]:seed_everything:"
  "--trainer[Path to a configuration file.]:trainer:"
……

tshu-w avatar Jun 22 '22 11:06 tshu-w