Skip to content

Commit

Permalink
Added ruff as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zwicker committed Aug 16, 2024
1 parent 39e5415 commit a61e39d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
31 changes: 11 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
[project]
name = "py-pde"
description = "Python package for solving partial differential equations"
authors = [{ name = "David Zwicker", email = "[email protected]" }]
license = { text = "MIT" }
authors = [
{name = "David Zwicker", email="[email protected]"}
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.9,<3.13"
dynamic = ["version"]
Expand All @@ -25,14 +27,7 @@ classifiers = [
]

# Requirements for setuptools
dependencies = [
"matplotlib>=3.1",
"numba>=0.59",
"numpy>=1.22",
"scipy>=1.10",
"sympy>=1.9",
"tqdm>=4.66",
]
dependencies = ["matplotlib>=3.1", "numba>=0.59", "numpy>=1.22", "scipy>=1.10", "sympy>=1.9", "tqdm>=4.66"]

[project.optional-dependencies]
io = ["h5py>=2.10", "pandas>=2", "ffmpeg-python>=0.2"]
Expand All @@ -45,12 +40,15 @@ documentation = "http://py-pde.readthedocs.io"
repository = "https://github.com/zwicker-group/py-pde"

[build-system]
requires = ["setuptools>=61", "setuptools_scm[toml]>=6.2"]
requires = [
"setuptools>=61",
"setuptools_scm[toml]>=6.2",
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true
zip-safe = false # required for mypy to find the py.typed file
zip-safe = false # required for mypy to find the py.typed file

[tool.setuptools.packages.find]
include = ["pde*"]
Expand Down Expand Up @@ -80,14 +78,7 @@ exclude = "scripts/templates"
profile = "black"
src_paths = ["pde", "examples", "scripts", "tests"]
known_self = ["pde", "fixtures"]
sections = [
"FUTURE",
"STDLIB",
"THIRDPARTY",
"FIRSTPARTY",
"SELF",
"LOCALFOLDER",
]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "SELF", "LOCALFOLDER"]

[tool.pytest.ini_options]
addopts = "--strict-markers"
Expand Down
15 changes: 14 additions & 1 deletion scripts/_templates/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ namespaces = false
[tool.setuptools_scm]
write_to = "pde/_version.py"

[tool.ruff]
target-version = "py39"
exclude = ["scripts/templates"]

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint.isort]
section-order = ["future", "standard-library", "third-party", "first-party", "self", "local-folder"]

[tool.ruff.lint.isort.sections]
self = ["pde", "fixtures"]

[tool.black]
target_version = ["py$MIN_PYTHON_VERSION_NODOT"]
exclude = "scripts/templates"
Expand Down Expand Up @@ -106,4 +119,4 @@ module = [
"sympy.*",
"tqdm.*",
]
ignore_missing_imports = true
ignore_missing_imports = true
9 changes: 4 additions & 5 deletions scripts/create_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,15 @@ def line(self, relation: str = ">=") -> str:
Requirement(
name="jupyter_contrib_nbextensions", version_min="0.5", tests_only=True
),
Requirement(name="black", version_min="24", tests_only=True),
Requirement(name="docformatter", version_min="1.7", tests_only=True),
Requirement(name="importlib-metadata", version_min="5", tests_only=True),
Requirement(name="isort", version_min="5.1", tests_only=True),
Requirement(name="mypy", version_min="1.8", tests_only=True),
Requirement(name="notebook", version_min="7", tests_only=True),
Requirement(name="pyupgrade", version_min="3", tests_only=True),
Requirement(name="pytest", version_min="5.4", tests_only=True),
Requirement(name="pytest-cov", version_min="2.8", tests_only=True),
Requirement(name="pytest-xdist", version_min="1.30", tests_only=True),
Requirement(name="ruff", version_min="0.6", tests_only=True),
]


Expand Down Expand Up @@ -279,7 +278,7 @@ def write_from_template(
path (:class:`Path`): The path where the requirements are written
template_name (str): The name of the template
requirements (list): The requirements to be written
fix_format (bool): If True, script will be formated using `black`
fix_format (bool): If True, script will be formatted using `ruff`
add_warning (bool): If True, adds a warning that file is generated
"""
print(f"Write `{path}`")
Expand Down Expand Up @@ -315,9 +314,9 @@ def write_from_template(
fp.writelines(SETUP_WARNING.format(template_name))
fp.writelines(content)

# call black formatter on it
# call ruff formatter on it
if fix_format:
sp.check_call(["black", "-q", "-t", "py38", str(path)])
sp.check_call(["ruff", "--config", "../pyproject.toml", str(path)])


def main():
Expand Down
3 changes: 1 addition & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
-r ../requirements.txt
black>=24
docformatter>=1.7
importlib-metadata>=5
isort>=5.1
jupyter_contrib_nbextensions>=0.5
mypy>=1.8
notebook>=7
pytest>=5.4
pytest-cov>=2.8
pytest-xdist>=1.30
pyupgrade>=3
ruff>=0.6

0 comments on commit a61e39d

Please sign in to comment.