gauge-sh / tach

A Python tool to enforce dependencies, using modular architecture 🌎 Open source 🐍 Installable via pip πŸ”§ Able to be adopted incrementally - ⚑ Implemented with no runtime impact ♾️ Interoperable with your existing systems πŸ¦€ Written in rust
https://gauge.sh
MIT License
953 stars 33 forks source link

Make --prune the default behavior of tach sync #147

Closed emdoyle closed 1 month ago

emdoyle commented 2 months ago

Right now, the default behavior of sync is additive, meaning that it will not remove any modules or configured dependencies. Instead it will add dependencies to existing modules to fix any boundary errors detected.

When using the --prune option, sync ignores the currently configured dependencies, and instead sets the dependencies for each module to the minimal set matching the actual imports found in the codebase. This behavior is more consistent with the idea of "syncing" your dependencies, and should be the default behavior when calling tach sync with no CLI arguments.

The current additive behavior should be enabled by passing a renamed flag: --add That is, tach sync will prune dependencies to the minimal set, while tach sync --add will add any missing dependencies.

NOTE: This issue interacts with #145 , and may require coordination if both are worked on simultaneously

dhananjaypai08 commented 1 month ago

@emdoyle The basic idea is to actually reverse the working, right? Where we had --prune as an argument to tach sync command this would call the sync::prune_dependency_constraints if --prune was true. Now we can have a diff argument called --add and whenever that is set to true we will just ignore calling the sync::prune_dependency_constraints. Is this the right way of thinking for this issue?

emdoyle commented 1 month ago

@dhananjaypai08 Yes, the idea is to reverse the conditional in sync.

When --add is set, we should call sync_dependency_constraints, but otherwise (by default) we should call prune_dependency_constraints. This is essentially a reversal of the if statement in sync.