Skip to content

[pre-commit.ci] pre-commit autoupdate #261

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

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ repos:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
1 change: 0 additions & 1 deletion fortls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ def debug_server_general(args, settings):
print("=======")
#
if args.debug_actions:

pp = pprint.PrettyPrinter(indent=2, width=120)
print('\nTesting "textDocument/getActions" request:')
check_request_params(args)
Expand Down
4 changes: 2 additions & 2 deletions fortls/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def find_paren_match(string: str) -> int:
"""
paren_count = 1
ind = -1
for (i, char) in enumerate(string):
for i, char in enumerate(string):
if char == "(":
paren_count += 1
elif char == ")":
Expand Down Expand Up @@ -568,7 +568,7 @@ def get_var_stack(line: str) -> list[str]:
return [""]
# Continuation of variable after paren requires '%' character
iLast = 0
for (i, section) in enumerate(sections):
for i, section in enumerate(sections):
if not line[section.start : section.end].startswith("%"):
iLast = i
final_var = ""
Expand Down
9 changes: 4 additions & 5 deletions fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ def map_types(type, in_class: bool = False):
# Add scopes to outline view
test_output = []
for scope in file_obj.ast.get_scopes():

if (
not scope.name # Skip empty strings
or scope.name.startswith("#") # Skip comments
Expand Down Expand Up @@ -472,7 +471,7 @@ def child_candidates(
else:
tmp_list: list[str] = []
tmp_rename: list[str] = []
for (var, rename) in zip(var_list, rename_list):
for var, rename in zip(var_list, rename_list):
var_name: str | None = rename
if var_name is None:
var_name = var.name
Expand Down Expand Up @@ -667,7 +666,7 @@ def build_comp(
candidate_list, rename_list = get_candidates(
scope_list, var_prefix, include_globals, public_only, abstract_only, no_use
)
for (candidate, rename) in zip(candidate_list, rename_list):
for candidate, rename in zip(candidate_list, rename_list):
# Skip module names (only valid in USE)
candidate_type = candidate.get_type()
if type_mask[candidate_type]:
Expand Down Expand Up @@ -944,7 +943,7 @@ def get_all_references(
for filename, file_obj in file_set:
file_refs = []
# Search through file line by line
for (i, line) in enumerate(file_obj.contents_split):
for i, line in enumerate(file_obj.contents_split):
if len(line) == 0:
continue
# Skip comment lines
Expand Down Expand Up @@ -1034,7 +1033,7 @@ def serve_references(self, request):
return None
all_refs, _ = self.get_all_references(def_obj, type_mem, file_obj=restrict_file)
refs = []
for (filename, file_refs) in all_refs.items():
for filename, file_refs in all_refs.items():
for ref in file_refs:
refs.append(
uri_json(path_to_uri(filename), ref[0], ref[1], ref[0], ref[2])
Expand Down
12 changes: 6 additions & 6 deletions fortls/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def add_children(mod_obj, query: str):

matching_symbols = []
query = query.lower()
for (_, obj_packed) in obj_tree.items():
for _, obj_packed in obj_tree.items():
top_obj = obj_packed[0]
top_uri = obj_packed[1]
if top_uri is not None:
Expand Down Expand Up @@ -877,7 +877,7 @@ def resolve_link(self, obj_tree):
ancestor_interfaces.append(prototype)
# Match interface definitions to implementations
for prototype in ancestor_interfaces:
for (i, child) in enumerate(self.children):
for i, child in enumerate(self.children):
if child.name.lower() == prototype.name.lower():
# Create correct object for interface
if child.get_type() == BASE_TYPE_ID:
Expand All @@ -893,7 +893,7 @@ def resolve_link(self, obj_tree):
child.copy_from(child_old)
# Replace in child and scope lists
self.children[i] = child
for (j, file_scope) in enumerate(child.file_ast.scope_list):
for j, file_scope in enumerate(child.file_ast.scope_list):
if file_scope is child_old:
child.file_ast.scope_list[j] = child
if child.get_type() == prototype.get_type():
Expand Down Expand Up @@ -965,7 +965,7 @@ def resolve_arg_link(self, obj_tree):
self.missing_args = []
for child in self.children:
ind = -1
for (i, arg) in enumerate(arg_list_lower):
for i, arg in enumerate(arg_list_lower):
if arg == child.name.lower():
ind = i
break
Expand Down Expand Up @@ -1069,7 +1069,7 @@ def get_docs_full(
def get_signature(self, drop_arg=-1):
arg_sigs = []
arg_list = self.args.split(",")
for (i, arg_obj) in enumerate(self.arg_objs):
for i, arg_obj in enumerate(self.arg_objs):
if i == drop_arg:
continue
if arg_obj is None:
Expand Down Expand Up @@ -1138,7 +1138,7 @@ def get_diagnostics(self):
if (implicit_flag is None) or implicit_flag:
return errors
arg_list = self.args.replace(" ", "").split(",")
for (i, arg_obj) in enumerate(self.arg_objs):
for i, arg_obj in enumerate(self.arg_objs):
if arg_obj is None:
arg_name = arg_list[i].strip()
new_diag = Diagnostic(
Expand Down
12 changes: 6 additions & 6 deletions fortls/parse_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,13 +1164,13 @@ def find_word_in_code_line(
word_range = find_word_in_line(curr_line.lower(), find_word_lower)
if backward and (word_range.start < 0):
back_lines.reverse()
for (i, line) in enumerate(back_lines):
for i, line in enumerate(back_lines):
word_range = find_word_in_line(line.lower(), find_word_lower)
if word_range.start >= 0:
line_no -= i + 1
return line_no, word_range
if forward and (word_range.start < 0):
for (i, line) in enumerate(forward_lines):
for i, line in enumerate(forward_lines):
word_range = find_word_in_line(line.lower(), find_word_lower)
if word_range.start >= 0:
line_no += i + 1
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def check_file(self, obj_tree, max_line_length=-1, max_comment_line_length=-1):
COMMENT_LINE_MATCH = FRegex.FIXED_COMMENT
else:
COMMENT_LINE_MATCH = FRegex.FREE_COMMENT
for (i, line) in enumerate(self.contents_split):
for i, line in enumerate(self.contents_split):
if COMMENT_LINE_MATCH.match(line) is None:
if 0 < max_line_length < len(line):
self.ast.add_error(
Expand Down Expand Up @@ -1891,7 +1891,7 @@ def format(docs: list[str]) -> str:
docstr = ""
has_args = True
idx_args = -1
for (i, line) in enumerate(docs):
for i, line in enumerate(docs):
if line.startswith("@brief"):
docstr += line.replace("@brief", "", 1).strip() + "\n"
elif line.startswith("@param"):
Expand Down Expand Up @@ -1940,7 +1940,7 @@ def add_line_comment(file_ast: FortranAST, docs: list[str]):
# most efficient implementation, see: shorturl.at/dfmyV
if len("".join(docs)) > 0:
file_ast.add_doc(format(docs), forward=predocmark)
for (i, doc_line) in enumerate(docs):
for i, doc_line in enumerate(docs):
log.debug(f"{doc_line} !!! Doc string - Line:{_ln + i}")
docs[:] = []
return ln
Expand Down Expand Up @@ -2093,7 +2093,7 @@ def replace_vars(line: str):
def_regexes = {}
output_file = []
def_cont_name = None
for (i, line) in enumerate(contents_split):
for i, line in enumerate(contents_split):
# Handle multiline macro continuation
if def_cont_name is not None:
output_file.append("")
Expand Down
2 changes: 1 addition & 1 deletion test/test_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def hover_req(file_path: str, ln: int, col: int) -> str:

def check_return(result_array, checks):
assert len(result_array) == len(checks)
for (i, check) in enumerate(checks):
for i, check in enumerate(checks):
assert result_array[i]["contents"]["value"] == check

root_dir = test_dir / "pp"
Expand Down
2 changes: 1 addition & 1 deletion test/test_server_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def check_return(result_array, checks, only_docs=False):
comm_lines = []
found_docs = False
idx = 0
for (i, hover_line) in enumerate(result_array["contents"]["value"].splitlines()):
for i, hover_line in enumerate(result_array["contents"]["value"].splitlines()):
if hover_line == "-----":
found_docs = True
if found_docs and only_docs:
Expand Down
2 changes: 1 addition & 1 deletion test/test_server_hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def hover_req(file_path: Path, ln: int, col: int) -> str:

def validate_hover(result_array: list, checks: list):
assert len(result_array) - 1 == len(checks)
for (i, check) in enumerate(checks):
for i, check in enumerate(checks):
assert result_array[i + 1]["contents"]["value"] == check


Expand Down
2 changes: 1 addition & 1 deletion test/test_server_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def validate_refs(result_array, checks):
def find_in_results(uri, sline):
for (i, result) in enumerate(result_array):
for i, result in enumerate(result_array):
if (result["uri"] == uri) and (result["range"]["start"]["line"] == sline):
del result_array[i]
return result
Expand Down
1 change: 0 additions & 1 deletion test/test_server_signature_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def test_subroutine_signature_help():


def test_intrinsics():

string = write_rpc_request(
1, "initialize", {"rootPath": str(test_dir / "signature")}
)
Expand Down