Skip to content
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

completion/pip: simplify control flow #1964

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

gaelicWizard
Copy link
Contributor

Description

Short-circuit the loader rather than indenting nearly the whole file.

Alsö, assign the _pip_completion() handler directly once it's loaded so that we get out of the way once we load it.

Motivation and Context

Indenting the entirety of the logic of the file just weirds me out...it alsö makes future diff's weird, and makes any whitespace changes look like the whole file was replaced.

Alsö, this function doesn't need to run ever once the real completion is loaded.

Alsö alsö, I feel like the _command_exists _pip_completion branch of the if statement will never be taken, no matter what else is loaded already. Won't eval "$(pip completion --bash)" register the full handler itself and then we never run?

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

Short-circuit the loader rather than indenting nearly the whole file.

ALSÖ, assign the `_pip_completion()` handler directly once it's loaded so that we get out of the way once we load it.
Copy link
Contributor

@davidpfarrell davidpfarrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes are good so I'll tentatively approve, but this logic is @NoahGorny 's pet project so I'll leave the final decision to them ...

NOTE: I like the "get out of the way" pattern !

@NoahGorny
Copy link
Member

Nice idea and greatly done!

@NoahGorny NoahGorny merged commit 8a1dc96 into Bash-it:master Sep 28, 2021
@gaelicWizard gaelicWizard deleted the completion-pip branch September 29, 2021 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants