11
11
from tach import __version__ , cache , extension , icons
12
12
from tach import filesystem as fs
13
13
from tach .check_external import check_external
14
- from tach .console import console , console_err
14
+ from tach .console import console_err
15
15
from tach .constants import CONFIG_FILE_NAME , TOOL_NAME
16
16
from tach .errors import (
17
17
TachCircularDependencyError ,
@@ -61,9 +61,10 @@ def print_unused_dependencies(
61
61
"[red bold]Unused Dependencies[/]\n " + f"[yellow]{ constraint_messages } [/]"
62
62
)
63
63
console_err .print (
64
- f"\n [yellow]Remove the unused dependencies from { CONFIG_FILE_NAME } .toml, "
64
+ f"\n Remove the unused dependencies from { CONFIG_FILE_NAME } .toml, "
65
65
f"or consider running '{ TOOL_NAME } sync' to update module configuration and "
66
- f"remove all unused dependencies.[/]\n "
66
+ f"remove all unused dependencies.\n " ,
67
+ style = "yellow" ,
67
68
)
68
69
69
70
@@ -95,12 +96,12 @@ def print_no_dependencies_found() -> None:
95
96
96
97
def print_show_web_suggestion (is_mermaid : bool = False ) -> None :
97
98
if is_mermaid :
98
- console .print (
99
+ console_err .print (
99
100
"NOTE: You are generating a Mermaid graph locally representing your module graph. For a remotely hosted visualization, use the '--web' argument.\n To visualize your graph, you will need to use Mermaid.js: https://mermaid.js.org/config/usage.html\n " ,
100
101
style = "cyan" ,
101
102
)
102
103
else :
103
- console .print (
104
+ console_err .print (
104
105
"NOTE: You are generating a DOT file locally representing your module graph. For a remotely hosted visualization, use the '--web' argument.\n To visualize your graph, you will need a program like GraphViz: https://www.graphviz.org/download/\n " ,
105
106
style = "cyan" ,
106
107
)
@@ -110,12 +111,12 @@ def print_generated_module_graph_file(
110
111
output_filepath : Path , is_mermaid : bool = False
111
112
) -> None :
112
113
if is_mermaid :
113
- console .print (
114
+ console_err .print (
114
115
f"Generated a Mermaid file containing your module graph at '{ output_filepath } '" ,
115
116
style = "green" ,
116
117
)
117
118
else :
118
- console .print (
119
+ console_err .print (
119
120
f"Generated a DOT file containing your module graph at '{ output_filepath } '" ,
120
121
style = "green" ,
121
122
)
@@ -568,9 +569,7 @@ def tach_check(
568
569
sys .exit (1 )
569
570
570
571
if exit_code == 0 and output_format == "text" :
571
- console .print (
572
- f"{ icons .SUCCESS } [green]All modules validated![/]" , style = "green"
573
- )
572
+ console_err .print (f"{ icons .SUCCESS } All modules validated!" , style = "green" )
574
573
sys .exit (exit_code )
575
574
576
575
@@ -603,9 +602,8 @@ def tach_check_external(
603
602
if has_errors :
604
603
sys .exit (1 )
605
604
else :
606
- console .print (
607
- f"{ icons .SUCCESS } [green]All external dependencies validated![/]" ,
608
- style = "green" ,
605
+ console_err .print (
606
+ f"{ icons .SUCCESS } All external dependencies validated!" , style = "green"
609
607
)
610
608
sys .exit (0 )
611
609
@@ -649,9 +647,9 @@ def tach_mod(
649
647
if warnings :
650
648
console_err .print ("\n " .join (warnings ))
651
649
if saved_changes :
652
- console .print (
653
- f"{ icons .SUCCESS } [green] Set modules! You may want to run '{ TOOL_NAME } sync' "
654
- f"to automatically set boundaries.[/] " ,
650
+ console_err .print (
651
+ f"{ icons .SUCCESS } Set modules! You may want to run '{ TOOL_NAME } sync' "
652
+ f"to automatically set boundaries." ,
655
653
style = "green" ,
656
654
)
657
655
sys .exit (0 )
@@ -681,7 +679,7 @@ def tach_sync(
681
679
print (str (e ))
682
680
sys .exit (1 )
683
681
684
- console .print (f"{ icons .SUCCESS } [green] Synced dependencies.[/] " , style = "green" )
682
+ console_err .print (f"{ icons .SUCCESS } Synced dependencies." , style = "green" )
685
683
sys .exit (0 )
686
684
687
685
@@ -712,14 +710,14 @@ def tach_install(project_root: Path, target: InstallTarget) -> None:
712
710
sys .exit (1 )
713
711
714
712
if installed :
715
- console .print (
716
- f"{ icons .SUCCESS } [green] Pre-commit hook installed to '.git/hooks/pre-commit'.[/] " ,
713
+ console_err .print (
714
+ f"{ icons .SUCCESS } Pre-commit hook installed to '.git/hooks/pre-commit'." ,
717
715
style = "green" ,
718
716
)
719
717
sys .exit (0 )
720
718
else :
721
- console .print (
722
- f"[yellow] Pre-commit hook could not be installed: { warning } [/] " ,
719
+ console_err .print (
720
+ f"Pre-commit hook could not be installed: { warning } " ,
723
721
style = "yellow" ,
724
722
)
725
723
sys .exit (1 )
@@ -807,8 +805,8 @@ def tach_show(
807
805
)
808
806
809
807
if is_web and is_mermaid :
810
- console .print (
811
- "[yellow] Passing --web generates a remote graph; ignoring '--mermaid' flag.[/] " ,
808
+ console_err .print (
809
+ "Passing --web generates a remote graph; ignoring '--mermaid' flag." ,
812
810
style = "yellow" ,
813
811
)
814
812
@@ -830,8 +828,8 @@ def tach_show(
830
828
included_paths = included_paths ,
831
829
)
832
830
if result :
833
- console .print ("View your dependency graph here:" )
834
- console .print (result )
831
+ console_err .print ("View your dependency graph here:" )
832
+ console_err .print (result )
835
833
sys .exit (0 )
836
834
else :
837
835
sys .exit (1 )
@@ -909,12 +907,12 @@ def tach_test(
909
907
)
910
908
if cached_output .exists :
911
909
# Early exit, cached terminal output was found
912
- console .print (
910
+ console_err .print (
913
911
"============ Cached results found! ============" ,
914
912
style = "green" ,
915
913
)
916
914
cached_output .replay ()
917
- console .print (
915
+ console_err .print (
918
916
"============ END Cached results ============" ,
919
917
style = "green" ,
920
918
)
@@ -1080,7 +1078,7 @@ def main(argv: list[str] = sys.argv[1:]) -> None:
1080
1078
1081
1079
latest_version = cache .get_latest_version (project_root )
1082
1080
if latest_version and current_version_is_behind (latest_version ):
1083
- console .print (
1081
+ console_err .print (
1084
1082
f"WARNING: there is a new { TOOL_NAME } version available"
1085
1083
f" ({ __version__ } -> { latest_version } ). Upgrade to remove this warning." ,
1086
1084
style = "yellow" ,
@@ -1115,7 +1113,7 @@ def main(argv: list[str] = sys.argv[1:]) -> None:
1115
1113
1116
1114
# Deprecation warnings
1117
1115
if project_config .use_regex_matching :
1118
- console .print (
1116
+ console_err .print (
1119
1117
"WARNING: regex matching for exclude paths is deprecated. "
1120
1118
+ f"Update your exclude paths in { CONFIG_FILE_NAME } .toml to use glob patterns instead, and remove the 'use_regex_matching' setting."
1121
1119
+ "\n " ,
@@ -1125,7 +1123,7 @@ def main(argv: list[str] = sys.argv[1:]) -> None:
1125
1123
project_config .root_module == "ignore"
1126
1124
and project_config .has_root_module_reference ()
1127
1125
):
1128
- console .print (
1126
+ console_err .print (
1129
1127
"WARNING: root module treatment is set to 'ignore' (default as of 0.23.0), but '<root>' appears in your configuration."
1130
1128
+ f"\n \n Run '{ TOOL_NAME } sync' to remove the root module from your dependencies,"
1131
1129
+ f" or update 'root_module' in { CONFIG_FILE_NAME } .toml to 'allow' or 'forbid' instead."
0 commit comments