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

[SNOW-1747456] Remove side effects from command registration #1945

Conversation

sfc-gh-pjob
Copy link
Contributor

@sfc-gh-pjob sfc-gh-pjob commented Dec 11, 2024

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

  • Introduced CliAppFactory, which wraps all callback definitions. Thanks to that, callbacks and commands are not registered globally but only within an instance of CliAppFactory. The factory exposes create_or_get_app method.
  • Removed global AppContextHolder in favour of get_click_context method exposed by CliAppFactory. Click context was and still is needed in tests traversing command tree (like docs generation tests).
  • Simplified commands_registration_with_callbacks.py.
    • The main change is removed before callback wrapper. It was used to invoke commands registration as soon as possible but IMO it's not needed to do it as soon as possible and we can invoke registration from commands_registration_callback after processing all eager CLI options (what we did anyway but previously only as a fallback, which wasn't needed).
  • Adjusted tests.

@sfc-gh-pjob sfc-gh-pjob force-pushed the pjob/SNOW-1747456-remove-side-effects-from-command-registration branch from 07dbd92 to daa3281 Compare December 19, 2024 17:56
@sfc-gh-pjob sfc-gh-pjob marked this pull request as ready for review December 19, 2024 17:56
@sfc-gh-pjob sfc-gh-pjob requested review from a team as code owners December 19, 2024 17:56
@sfc-gh-pjob sfc-gh-pjob force-pushed the pjob/SNOW-1747456-remove-side-effects-from-command-registration branch from ecaa03f to c035544 Compare January 21, 2025 17:24
@sfc-gh-pjob sfc-gh-pjob merged commit 7458427 into main Jan 23, 2025
20 checks passed
@sfc-gh-pjob sfc-gh-pjob deleted the pjob/SNOW-1747456-remove-side-effects-from-command-registration branch January 23, 2025 13:15
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.

3 participants