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

Remove explicitly imported function from implicit imports. #75

Merged
merged 3 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions amarna/Result.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __eq__(self, other: object) -> bool:
class ResultMultiplePositions:
def __init__(
self,
filenames: str,
filenames: List[str],
rule_name: str,
text: str,
position_list: List[PositionType],
Expand Down Expand Up @@ -143,7 +143,7 @@ def create_result_token(filename: str, rule_name: str, text: str, token: Token)


def result_multiple_positions(
filenames: str,
filenames: List[str],
rule_name: str,
text: str,
position_list: List[PositionType],
Expand Down
2 changes: 1 addition & 1 deletion amarna/amarna.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_all_rule_names() -> List[str]:
)

@staticmethod
def print_rule_names_and_descriptions() -> List[str]:
def print_rule_names_and_descriptions() -> None:
ruleset = Amarna.load_classes_in_module(local_rules_module) + Amarna.load_classes_in_module(
post_process_rules_module
)
Expand Down
4 changes: 4 additions & 0 deletions amarna/rules/post_process_rules/ImplicitImportRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def run_rule(self, gathered_data: Dict) -> List[ResultMultiplePositions]:
if imp.file_location in files_marked:
continue

# ignore explicitely imported functions
if imp.import_name == func.name:
continue

files_marked.append(imp.file_location)

result = result_multiple_positions(
Expand Down
3 changes: 3 additions & 0 deletions tests/implicit_import_test_two/proxy.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%lang starknet
fcasal marked this conversation as resolved.
Show resolved Hide resolved

from utils import auth_read_storage
29 changes: 29 additions & 0 deletions tests/implicit_import_test_two/utils.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%lang starknet

from starkware.starknet.common.syscalls import storage_read, storage_write, get_caller_address

# Helpers for auth users to interact with contract's storage
@view
func auth_read_storage{
syscall_ptr : felt*,
}(auth_account : felt, address : felt) -> (value : felt):
let (caller) = get_caller_address()

assert caller = auth_account

let (value) = storage_read(address=address)

return (value=value)
end

@external
func auth_write_storage{
syscall_ptr : felt*,
}(auth_account : felt, address : felt, value : felt):
let (caller) = get_caller_address()

assert caller = auth_account

storage_write(address=address, value=value)
return()
end