Skip to content

Commit

Permalink
Enable C linting rules (excl C901) (#204)
Browse files Browse the repository at this point in the history
Partially addresses #165.

I enabled C linting rules but added C901 ("function is too complex") to
the ignore list.
  • Loading branch information
ddundo authored Jun 26, 2024
1 parent 04b6df7 commit a66362b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions goalie/mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ def __init__(self, time_partition, initial_meshes, **kwargs):
"""
self.time_partition = time_partition
self.fields = {field_name: None for field_name in time_partition.field_names}
self.field_types = {
field: field_type
for field, field_type in zip(self.fields, time_partition.field_types)
}
self.field_types = dict(zip(self.fields, time_partition.field_types))
self.subintervals = time_partition.subintervals
self.num_subintervals = time_partition.num_subintervals
self.set_meshes(initial_meshes)
Expand Down
2 changes: 1 addition & 1 deletion goalie/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _check_value(self, key, possibilities):
)

def __str__(self):
return str({key: value for key, value in self.items()})
return str(dict(self.items()))

def __repr__(self):
d = ", ".join([f"{key}={value}" for key, value in self.items()])
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ line-length = 88
[tool.ruff.lint]
select = [
"B", # flake8-bugbear
# "C", # mccabe complexity TODO: enable this (#165)
"C", # mccabe complexity
"E", "W", # Pycodestyle
"F", # Pyflakes
"I", # isort
]
ignore = [
"C901", # function is too complex (TODO #165: enable this)
"E501", # line too long
"E203", # whitespace before ':'
"E226", # missing whitespace around arithmetic operator
Expand Down
2 changes: 1 addition & 1 deletion test/test_mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_return_dict_error(self, method):
funcs = [lambda _: 0, lambda _: 0, lambda _: lambda *_: 0]
methods_map = dict(zip(methods, funcs))
if method == "get_form":
kwargs = {method: func for method, func in methods_map.items()}
kwargs = methods_map
f_space = FunctionSpace(mesh, "CG", 1)
kwargs["get_function_spaces"] = lambda _: {"field": f_space}
kwargs["get_initial_condition"] = lambda _: {"field": Function(f_space)}
Expand Down

0 comments on commit a66362b

Please sign in to comment.