Skip to content

Commit

Permalink
migrate linting from flake8, isort, autoflake to ruff (same as atomat…
Browse files Browse the repository at this point in the history
…e2, jobflow now)
  • Loading branch information
janosh authored and gpetretto committed Jun 10, 2024
1 parent bef4bc9 commit a74175d
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 113 deletions.
48 changes: 12 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,27 @@
default_language_version:
python: python3.9
#exclude: '^src/{{ package_name }}/some/directory/'
python: python3
exclude: ^(.github/|tests/test_data/abinit/)
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/myint/autoflake
rev: v2.2.1
hooks:
- id: autoflake
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
exclude: README.md
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
entry: pflake8
files: ^src/
additional_dependencies:
- pyproject-flake8
- flake8-bugbear
- flake8-typing-imports
- flake8-docstrings
- flake8-rst-docstrings
- flake8-rst
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand All @@ -49,23 +30,18 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.10.0
hooks:
- id: mypy
files: ^src/
additional_dependencies:
- tokenize-rt==4.1.0
- types-pkg_resources==0.1.2
- types-paramiko
- pydantic~=2.0
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, 'titel,statics,ba,nd,te,nin', --skip, '*.svg']
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
args: [--ignore-words-list, 'titel,statics,ba,nd,te']
types_or: [python, rst, markdown]
4 changes: 1 addition & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import os
import sys

# sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
)
import jobflow_remote

# -- Project information -----------------------------------------------------

Expand All @@ -26,8 +26,6 @@
author = "Guido Petretto, Matthew Evans, David Waroquiers"


import jobflow_remote

# The short X.Y version
version = jobflow_remote.__version__
# The full version, including alpha/beta/rc tags
Expand Down
75 changes: 25 additions & 50 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[build-system]
requires = ["setuptools >= 42", "versioningit ~= 1.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "jobflow-remote"
description = "Jobflow Remote is a Python package to run jobflow workflows on remote resources"
Expand All @@ -11,50 +7,44 @@ license = { text = "modified BSD" }
authors = [{ name = "Guido Petretto", email = "[email protected]" }]
dynamic = ["version"]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"Intended Audience :: Information Technology",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.9",
"Topic :: Other/Nonlisted Topic",
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.9"
dependencies =[
dependencies = [
"fabric ~= 3.2",
"flufl.lock ~= 8.0",
"jobflow >= 0.1.14",
"psutil ~= 5.9",
"pydantic ~= 2.4",
"fabric ~= 3.2",
"tomlkit ~= 0.12",
"qtoolkit ~= 0.1, >= 0.1.4",
"typer ~= 0.9",
"rich ~= 13.7",
"psutil ~= 5.9",
"supervisor ~= 4.2",
"ruamel.yaml ~= 0.17",
"schedule ~= 1.2",
"flufl.lock ~= 8.0"
"supervisor ~= 4.2",
"tomlkit ~= 0.12",
"typer ~= 0.9",
]

[project.optional-dependencies]
dev = [
"pre-commit>=3.0.0",
]
tests = [
"pytest ~= 8.0",
"pytest-cov ~= 4.0",
"docker ~= 7.0",
]
dev = ["pre-commit>=3.0.0"]
tests = ["docker ~= 7.0", "pytest ~= 8.0", "pytest-cov ~= 4.0"]
docs = [
"sphinx",
"sphinx_design",
"autodoc_pydantic>=2.0.0",
"pydata-sphinx-theme",
"sphinx",
"sphinx-copybutton",
"autodoc_pydantic>=2.0.0",
"sphinxcontrib-mermaid"
"sphinx_design",
"sphinxcontrib-mermaid",
]

[project.scripts]
Expand All @@ -69,22 +59,14 @@ changelog = "https://matgenix.github.io/jobflow-remote/changelog"
[tool.setuptools.package-data]
jobflow_remote = ["py.typed"]

[build-system]
requires = ["setuptools >= 42", "versioningit ~= 1.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.versioningit.vcs]
method = "git"
default-tag = "0.0.1"

[tool.isort]
profile = "black"

[tool.flake8]
max-line-length = 88
max-doc-length = 88
select = "C, E, F, W, B"
extend-ignore = "E203, W503, E501, F401, RST21"
min-python-version = "3.9.0"
docstring-convention = "numpy"
rst-roles = "class, func, ref, obj"

[tool.mypy]
ignore_missing_imports = true
strict_optional = false
Expand All @@ -104,9 +86,9 @@ warn_required_dynamic_aliases = true
[tool.pytest.ini_options]
filterwarnings = [
"ignore:.*POTCAR.*:UserWarning",
"ignore:.*magmom.*:UserWarning",
"ignore:.*is not gzipped.*:UserWarning",
"ignore:.*input structure.*:UserWarning",
"ignore:.*is not gzipped.*:UserWarning",
"ignore:.*magmom.*:UserWarning",
"ignore::DeprecationWarning",
]

Expand All @@ -122,14 +104,7 @@ source = ["src/"]
skip_covered = true
show_missing = true
exclude_lines = [
'^\s*@overload( |$)',
'^\s*assert False(,|$)',
'if typing.TYPE_CHECKING:',
'^\s*@overload( |$)',
]

[tool.autoflake]
in-place = true
remove-all-unused-imports = true
remove-unused-variables = true
ignore-init-module-imports = true
expand-star-imports = true
1 change: 1 addition & 0 deletions src/jobflow_remote/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
# Import the submodules with a local app to register them to the main app
import jobflow_remote.cli.admin
import jobflow_remote.cli.execution
Expand Down
2 changes: 1 addition & 1 deletion src/jobflow_remote/cli/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def stop(
"Wait until the daemon has stopped. NOTE: this may take a while if a large file is being transferred!"
),
),
] = False
] = False,
):
"""
Send a stop signal to the Runner processes.
Expand Down
1 change: 0 additions & 1 deletion src/jobflow_remote/remote/host/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def _create_connection(self):
# if the authentication is ssh-key + OTP paramiko already
# handles it. Don't use the alternative strategy.
if not self._connection.connect_kwargs.get("key_filename"):

if not config:
config = Config()
config.authentication.strategy_class = InteractiveAuthStrategy
Expand Down
2 changes: 0 additions & 2 deletions src/jobflow_remote/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ def self_replace(n: int):
"""
Create a replace Job with the same job n times.
"""
from jobflow import Flow

if n > 0:
return Response(replace=self_replace(n - 1))

Expand Down
4 changes: 2 additions & 2 deletions src/jobflow_remote/testing/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def run_check_cli(
)

# note that stderr is not captured separately
assert error == (
result.exit_code != 0
assert (
error == (result.exit_code != 0)
), f"cli should have {'not ' if not error else ''}failed. exit code: {result.exit_code}. stdout: {result.stdout}"

if required_out:
Expand Down
3 changes: 0 additions & 3 deletions tests/db/cli/test_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def test_flows_list(job_controller, four_jobs):

from jobflow_remote.testing.cli import run_check_cli

columns = ["DB id", "Name", "State", "Flow id", "Num Jobs", "Last updated"]
Expand All @@ -19,7 +18,6 @@ def test_flows_list(job_controller, four_jobs):


def test_delete(job_controller, four_jobs):

from jobflow_remote.testing.cli import run_check_cli

run_check_cli(
Expand All @@ -40,7 +38,6 @@ def test_delete(job_controller, four_jobs):


def test_flow_info(job_controller, four_jobs):

from jobflow_remote.testing.cli import run_check_cli

columns = ["DB id", "Name", "State", "Job id", "(Index)", "Worker"]
Expand Down
Loading

0 comments on commit a74175d

Please sign in to comment.