Skip to content

Commit

Permalink
chore: add ruff config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Jan 3, 2025
1 parent de3e86d commit b2a730a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ fmt: format
.PHONY: fmt

isort: ## Run ruff isort fixes over the source code
ruff check --fix --select=I scripts
ruff check --fix --select=RUF022 scripts
ruff check --fix --config python/pyproject.toml --select=I scripts
ruff check --fix --config python/pyproject.toml --select=RUF022 scripts
@echo -e "\e[1;32mruff isort clean!\e[0m"
.PHONY: isort

black: ## Run ruff format over the source code
ruff format scripts
ruff format --config python/pyproject.toml scripts
@echo -e "\e[1;32mruff format clean!\e[0m"
.PHONY: black

Expand Down Expand Up @@ -53,7 +53,7 @@ clippy: ## Run clippy lint checks
.PHONY: clippy

ruff: ## Run ruff checks over the source code
ruff check python scripts
ruff check --config python/pyproject.toml python scripts
@echo -e "\e[1;32mruff lint clean!\e[0m"
.PHONY: ruff

Expand Down
47 changes: 47 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,53 @@ bindings = "pyo3"
module-name = "pymittagleffler._bindings"
python-source = "src"

[tool.ruff]
target-version = "py310"
line-length = 88

preview = true
lint.select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E", # flake8
"F", # flake8
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # flake8-isort
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"NPY", # numpy
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RUF", # ruff
"S", # flake8-bandit
"SIM", # flake8-simplify
"UP", # pyupgrade
"W", # flake8
]
lint.ignore = [
"E203", # whitespace-before-punctuation
"E402", # module-import-not-at-top-of-file
"ISC001", # single-line-implicit-string-concatenation
"N803", # non-lowercase-argument
"N806", # non-lowercase-variable-in-function
"S101", # assert
"S102", # exec-builtin
"UP037", # quoted-annotation
]

lint.flake8-quotes.docstring-quotes = "double"
lint.flake8-quotes.inline-quotes = "double"
lint.flake8-quotes.multiline-quotes = "double"
lint.isort.force-wrap-aliases = true
lint.isort.known-first-party = [
"pymittagleffler",
]
lint.isort.required-imports = [
"from __future__ import annotations",
]

[tool.pytest]
testpaths = [ "tests" ]
cache_dir = ".pytest-cache"
Expand Down
1 change: 1 addition & 0 deletions python/src/pymittagleffler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-FileCopyrightText: 2023 Alexandru Fikl <[email protected]>
# SPDX-License-Identifier: MIT
from __future__ import annotations

from ._bindings import GarrappaMittagLeffler, mittag_leffler

Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_mittag_leffler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_mittag_leffler_scalar() -> None:
_ = mittag_leffler(z, alpha, beta)
print(f"({type(z)}, {type(_)}): {_} {np.exp(z + 0j)}")

z = "1.0"
with pytest.raises(TypeError):
z = "1.0"
_ = mittag_leffler(z, alpha, beta)


Expand Down

0 comments on commit b2a730a

Please sign in to comment.