Skip to content

Commit

Permalink
Replace isort and flake8 with ruff, upgrade hooks (#272)
Browse files Browse the repository at this point in the history
* Replace isort and flake8 with ruff, upgrade hooks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove 82 line length config

* Run pre-commit on all

* Rm commented out isort config

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ashwinvis and pre-commit-ci[bot] committed Feb 6, 2023
1 parent 509a01e commit 43843f0
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 30 deletions.
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ repos:
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.241
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- id: ruff
- repo: https://github.com/snakemake/snakefmt
rev: v0.8.0
rev: v0.8.1
hooks:
- id: snakefmt
- repo: https://github.com/executablebooks/mdformat
Expand Down
5 changes: 4 additions & 1 deletion docs/debug/gh-163-snakemake-resources/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from snakemake import snakemake

make = partial(
snakemake, snakefile="Snakefile", targets=("earth", "space"), printshellcmds=True
snakemake,
snakefile="Snakefile",
targets=("earth", "space"),
printshellcmds=True,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class OutputCanonical(OutputBase):

template_box = box
template_makefile_usr = makefile_usr
template_size = size
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/snek5000-tgv/src/snek5000_tgv/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def create_default_params(cls):

# Read defaults for `params.nek` from `tgv.par.cfg` (original code)
complete_params_from_par_file(
params, Path(__file__).parent / f"{cls.info_solver.short_name}.par.cfg"
params,
Path(__file__).parent / f"{cls.info_solver.short_name}.par.cfg",
)

# Boundary conditions
Expand Down
11 changes: 9 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ def ctags(session):
)
)
run_ext(
session, f"ctags -f {output} --language-force=Fortran -R {sources['nek5000']}"
session,
f"ctags -f {output} --language-force=Fortran -R {sources['nek5000']}",
)
run_ext(session, f"ctags -f {output} {excludes} --append -R {sources['snek5000']}")

Expand Down Expand Up @@ -382,7 +383,13 @@ def release_tests(session, dist_type):
), "Poetry local configuration exists. Please remove to continue"
session.install("poetry")
session.run(
"python", "-m", "poetry", "config", "--local", "virtualenvs.create", "false"
"python",
"-m",
"poetry",
"config",
"--local",
"virtualenvs.create",
"false",
)
pytest_cmd = install_with_tests(session, ["--no-root"])
else:
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "src/snek5000/_version.py"

[tool.isort]
known_first_party = ["fluiddyn", "fluidsim_core", "snek5000"]
# multi_line_output = 3
profile = "black"
line_length = 82
[tool.ruff]
ignore = ["E501", "W505"]

[tool.ruff.isort]
known-first-party = ["fluiddyn", "fluidsim_core", "snek5000"]

[tool.coverage.run]
source = ["snek5000", "snek5000_canonical", "./tests"]
Expand Down
10 changes: 8 additions & 2 deletions src/snek5000/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def _init_root(self):
self._set_child("classes")
self.classes._set_child(
"Oper",
attribs={"module_name": "snek5000.operators", "class_name": "Operators"},
attribs={
"module_name": "snek5000.operators",
"class_name": "Operators",
},
)


Expand All @@ -64,7 +67,10 @@ def _init_root(self):
super()._init_root()
self.classes._set_child(
"Output",
attribs={"module_name": "snek5000.output.base", "class_name": "Output"},
attribs={
"module_name": "snek5000.output.base",
"class_name": "Output",
},
)
self.classes._set_child(
"Make", attribs={"module_name": "snek5000.make", "class_name": "Make"}
Expand Down
1 change: 0 additions & 1 deletion src/snek5000/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Make:
"""

def __init__(self, sim=None, path_run=None):

if (sim is None and path_run is None) or (
sim is not None and path_run is not None
):
Expand Down
3 changes: 2 additions & 1 deletion src/snek5000/output/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def _set_info_solver_classes(cls, classes):
classes._set_child(
"HistoryPoints",
dict(
module_name="snek5000.output.history_points", class_name="HistoryPoints"
module_name="snek5000.output.history_points",
class_name="HistoryPoints",
),
)

Expand Down
2 changes: 0 additions & 2 deletions src/snek5000/output/history_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def load(self):
return self.coords, self._data

def _load_full(self):

with open(self.path_file) as file:
nb_points = int(file.readline().split(" ", 1)[0])
coords = np.loadtxt(file, max_rows=nb_points)
Expand All @@ -148,7 +147,6 @@ def _load_full(self):
return self.coords, df

def _create_df_from_lines(self, lines, nb_points):

columns = ["time", "ux", "uy"]

sim = self.output.sim
Expand Down
1 change: 0 additions & 1 deletion src/snek5000/output/remaining_clock_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def _load_times(self):
return data

def load(self):

if not self.path_file.exists():
raise IOError(
f"No file {self.path_file}. "
Expand Down
3 changes: 2 additions & 1 deletion src/snek5000/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def load_params(path_dir="."):
Simul = import_cls_simul(short_name)

return Simul.load_params_from_file(
path_xml=path_dir / "params_simul.xml", path_par=path_dir / f"{short_name}.par"
path_xml=path_dir / "params_simul.xml",
path_par=path_dir / f"{short_name}.par",
)


Expand Down
1 change: 0 additions & 1 deletion src/snek5000/util/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def print_versions():

import pymech
import snakemake

Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def sim_tgv_executed():


def create_fake_nek_files(path_dir, name_solver, nb_files=1):

nx = 2
ny = 4
nz = 6
Expand Down
1 change: 0 additions & 1 deletion tests/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def format_par(text):


def test_user_params():

tmp_dir = Path(tempfile.mkdtemp("snek5000", __name__))

def complete_create_default_params(p):
Expand Down

0 comments on commit 43843f0

Please sign in to comment.