Skip to content

Commit 46a166b

Browse files
committed
update imports to only import when necessary
1 parent 87176fd commit 46a166b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

spice/analyze.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import os
22

3-
# import utils
4-
from spice.utils.get_lexer import get_lexer_for_file
5-
6-
# import analyzer functions from analyzers folder
7-
from spice.analyzers.count_lines import count_lines
8-
from spice.analyzers.count_comment_lines import count_comment_lines
9-
from spice.analyzers.count_functions import count_functions
10-
113
# gustavo testando alguma coisa
124
from spice.analyzers.identation import detect_indentation
135

@@ -40,10 +32,12 @@ def analyze_file(file_path: str, selected_stats=None):
4032

4133
# line count if requested
4234
if "line_count" in selected_stats:
35+
from spice.analyzers.count_lines import count_lines
4336
results["line_count"] = count_lines(code)
4437

4538
# comment line count if requested
4639
if "comment_line_count" in selected_stats:
40+
from spice.analyzers.count_comment_lines import count_comment_lines
4741
results["comment_line_count"] = count_comment_lines(code)
4842

4943
# @gtins botei sua funcao aqui pq ela usa o codigo raw e nao o tokenizado, ai so tirei ela ali de baixo pra nao ficar chamando o parser sem precisar
@@ -56,6 +50,7 @@ def analyze_file(file_path: str, selected_stats=None):
5650
if "function_count" in selected_stats:
5751

5852
# get the lexer for the code's language
53+
from spice.utils.get_lexer import get_lexer_for_file
5954
LexerClass = get_lexer_for_file(file_path)
6055

6156
# tokenize the code via lexer
@@ -73,6 +68,7 @@ def analyze_file(file_path: str, selected_stats=None):
7368
ast = parser.parse()
7469

7570
# count functions
71+
from spice.analyzers.count_functions import count_functions
7672
results["function_count"] = count_functions(ast)
7773

7874
return results

0 commit comments

Comments
 (0)