Skip to content

Commit

Permalink
chore(formatting): switch to ruff (#166)
Browse files Browse the repository at this point in the history
* replace isort/black/pylint/flake8
* keep settings mostly identical
* run ruff check --select NPY201, no changes needed
  • Loading branch information
wpbonelli committed Apr 1, 2024
1 parent 77a159e commit b8c5588
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 81 deletions.
29 changes: 0 additions & 29 deletions .flake8

This file was deleted.

33 changes: 6 additions & 27 deletions .github/workflows/pymake-linting-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,13 @@ jobs:
uses: ts-graphviz/setup-graphviz@v2

- name: Install packages
run: |
pip install requests pydotplus appdirs numpy matplotlib
pip install https://github.com/modflowpy/flopy/zipball/develop
pip install pylint flake8 black
run: pip install ".[lint]"

- name: Run isort
run: |
echo "if isort check fails update isort using"
echo " pip install isort --upgrade"
echo "and run"
echo " isort ./flopy"
echo "and then commit the changes."
isort --verbose --check --diff ./pymake
- name: Run black
run: |
echo "if black check fails update black using"
echo " pip install black --upgrade"
echo "and run"
echo " black ./flopy"
echo "and then commit the changes."
black --check --diff ./pymake
- name: Run flake8
run: flake8 --count --show-source --exit-zero ./pymake

- name: Run pylint
run: pylint --jobs=2 --errors-only --exit-zero ./pymake
- name: Lint
run: ruff check .

- name: Check format
run: ruff format . --check

pymake_setup:
name: standard installation
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ docs/source/
venv/

# mac files
**/.DS_Store
**/.DS_Store

# environment files
**.env
1 change: 1 addition & 0 deletions pymake/cmds/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This script originates from pymake: https://github.com/modflowpy/pymake
It requires Python 3.6 or later, and has no dependencies.
"""

import sys
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions pymake/cmds/createjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This script originates from pymake: https://github.com/modflowpy/pymake
It requires Python 3.6 or later, and has no dependencies.
"""

import sys
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions pymake/cmds/mfpymakecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This script originates from pymake: https://github.com/modflowpy/pymake
It requires Python 3.6 or later, and has no dependencies.
"""

import sys
from pathlib import Path

Expand Down
4 changes: 1 addition & 3 deletions pymake/utils/_Popen_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Private functions for running pymake commands using Popen
"""
"""Private functions for running pymake commands using Popen"""

import sys
from subprocess import PIPE, STDOUT, Popen
Expand Down
3 changes: 1 addition & 2 deletions pymake/utils/_compiler_language_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Private functions for processing c/c++ and fortran files
"""
"""Private functions for processing c/c++ and fortran files"""

import os

Expand Down
6 changes: 3 additions & 3 deletions pymake/utils/usgsprograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ def export_json(
tzinfo=datetime.timezone.utc
)
datetime_str = datetime_obj_utc.strftime("%m/%d/%Y")
prog_data[target][
"url_download_asset_date"
] = datetime_str
prog_data[target]["url_download_asset_date"] = (
datetime_str
)
break

if partial_json:
Expand Down
40 changes: 24 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ dependencies = [
dynamic = ["version", "readme"]
[project.optional-dependencies]
lint = [
"black",
"cffconvert",
"flake8",
"isort",
"pylint",
"ruff",
]
test = [
"mfpymake[lint]",
Expand Down Expand Up @@ -90,18 +87,29 @@ include = ["pymake", "pymake.*"]
[tool.setuptools.package-data]
"pymake.utils" = ["usgsprograms.txt"]

[tool.black]
line-length = 79
target_version = ["py38"]
[tool.setuptools_scm]
fallback_version = "999"

[tool.flynt]
[tool.ruff]
line-length = 79
verbose = true

[tool.isort]
profile = "black"
src_paths = ["pymake", "autotest", "examples"]
line_length = 79
target-version = "py38"
include = [
"pyproject.toml",
"pymake/**/*.py",
"autotest/**/*.py",
"docs/**/*.py",
]

[tool.setuptools_scm]
fallback_version = "999"
[tool.ruff.lint]
ignore = [
"E402", # module level import not at top of file
"E712", # Avoid equality comparisons to `True`
"E722", # do not use bare `except`
"E741", # ambiguous variable name
"F401", # unused import
"F403", # unable to detect undefined names (star imports)
"F524", # `.format` missing argument(s) for placeholder(s)
"F811", # Redefinition of unused variable
"F821", # undefined name TODO FIXME
"F841", # local variable assigned but never used
]

0 comments on commit b8c5588

Please sign in to comment.