Skip to content

Commit

Permalink
moved linter from prospector to ruff, updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
richrobe committed Nov 24, 2023
1 parent d29cdb4 commit c3c3d36
Show file tree
Hide file tree
Showing 7 changed files with 710 additions and 506 deletions.
57 changes: 0 additions & 57 deletions .prospector.yml

This file was deleted.

116 changes: 116 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
line-length = 120
target-version = "py39"

select = [
# pyflakes
"F",
# pycodestyle
"E",
"W",
# mccabe
"C90",
# isort
"I",
# pydocstyle
"D",
# pyupgrade
"UP",
# pep8-naming
"N",
# flake8-blind-except
"BLE",
# flake8-2020
"YTT",
# flake8-builtins
"A",
# flake8-comprehensions
"C4",
# flake8-debugger
"T10",
# flake8-errmsg
"EM",
# flake8-implicit-str-concat
"ISC",
# flake8-pytest-style
"PT",
# flake8-return
"RET",
# flake8-simplify
"SIM",
# flake8-unused-arguments
"ARG",
# pandas-vet
"PD",
# pygrep-hooks
"PGH",
# flake8-bugbear
"B",
# flake8-quotes
"Q",
# pylint
"PL",
# flake8-pie
"PIE",
# flake8-type-checking
"TCH",
# tryceratops
"TRY",
# flake8-use-pathlib
"PTH",
"RUF",
# Numpy rules
"NPY",
# Implicit namespace packages
"INP",
# No relative imports
"TID252",
# f-strings over string concatenation
"FLY",
]

ignore = [
# controversial
"B006",
# controversial
"B008",
"B010",
# Magic constants
"PLR2004",
# Strings in error messages
"EM101",
"EM102",
"EM103",
# Exception strings
"TRY003",
# Varaibles before return
"RET504",
# Abstract raise into inner function
"TRY301",
# df as varaible name
"PD901",
# melt over stack
"PD013",
# No Any annotations
"ANN401",
# To many arguments
"PLR0913",
# Ignore because of formatting
"ISC001",
]


exclude = [
"doc/sphinxext/*.py",
"doc/build/*.py",
"doc/temp/*.py",
".eggs/*.py",
"example_data",
]


[pydocstyle]
convention = "numpy"

[pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true
11 changes: 1 addition & 10 deletions _tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import platform
import re
import subprocess
import sys
Expand All @@ -7,14 +6,6 @@
HERE = Path(__file__).parent


def task_docs():
"""Build the html docs using Sphinx."""
if platform.system() == "Windows":
return subprocess.run([HERE / "docs/make.bat", "html"])
else:
return subprocess.run(["make", "-C", HERE / "docs", "html"])


def update_version_strings(file_path, new_version):
# taken from:
# https://stackoverflow.com/questions/57108712/replace-updated-version-strings-in-files-via-python
Expand All @@ -25,7 +16,7 @@ def update_version_strings(file_path, new_version):
f.write(
re.sub(
version_regex,
lambda match: '{}{}"'.format(match.group(1), new_version),
lambda match: f'{match.group(1)}{new_version}"',
content,
)
)
Expand Down
9 changes: 5 additions & 4 deletions hpc_helper/_hpc_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import subprocess
import sys
import warnings
from collections.abc import Sequence
from pathlib import Path
from typing import Literal, Optional, Sequence, get_args
from typing import Literal, Optional, get_args

from hpc_helper._types import path_t

Expand Down Expand Up @@ -193,6 +194,7 @@ def build_job_submit_torque(
f"Using torque for '{target_system}' is deprecated. "
f"Please consider migrating your submission scripts to slurm!",
category=DeprecationWarning,
stacklevel=2,
)
# qsub = _check_command_for_target_system("qsub", target_system)
qsub_command = f"qsub.{target_system} -N {job_name} -l nodes={nodes}:ppn={ppn},walltime={walltime} -m abe "
Expand Down Expand Up @@ -281,9 +283,8 @@ def build_job_submit_slurm(
_check_partition_slurm(partition, gres)
sbatch_command += f"--partition={partition} "
sbatch_command += f"--gres={gres} "
if target_system == "tinyfat":
if partition is not None:
sbatch_command += f"-p {partition} "
if target_system == "tinyfat" and partition is not None:
sbatch_command += f"-p {partition} "
sbatch_command += f"--time={walltime} --mail-type={mail_type} "

sbatch_command = _add_arguments_slurm(sbatch_command, args, **kwargs)
Expand Down
Loading

0 comments on commit c3c3d36

Please sign in to comment.