Skip to content

Commit 4bcbd06

Browse files
committed
update own Makefile
1 parent e5eddbd commit 4bcbd06

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ MXMAKE?=-e .
111111
# Default: src
112112
RUFF_SRC?=src
113113

114+
# Enable ruff check --fix when running ruff-format.
115+
# Set to `true` to enable automatic fixes.
116+
# Default: false
117+
RUFF_FIXES?=false
118+
119+
# Enable unsafe fixes when RUFF_FIXES is enabled.
120+
# Set to `true` to enable unsafe fixes.
121+
# Default: false
122+
RUFF_UNSAFE_FIXES?=false
123+
114124
## qa.isort
115125

116126
# Source folder to scan for Python files to run isort on.
@@ -352,6 +362,15 @@ ifeq ($(RUFF_SRC),src)
352362
RUFF_SRC:=$(PYTHON_PROJECT_PREFIX)src
353363
endif
354364

365+
# Build ruff check flags based on settings
366+
ifeq ("$(RUFF_FIXES)","true")
367+
ifeq ("$(RUFF_UNSAFE_FIXES)","true")
368+
RUFF_FIX_FLAGS=--fix --unsafe-fixes
369+
else
370+
RUFF_FIX_FLAGS=--fix
371+
endif
372+
endif
373+
355374
RUFF_TARGET:=$(SENTINEL_FOLDER)/ruff.sentinel
356375
$(RUFF_TARGET): $(MXENV_TARGET)
357376
@echo "Install Ruff"
@@ -367,6 +386,10 @@ ruff-check: $(RUFF_TARGET)
367386
ruff-format: $(RUFF_TARGET)
368387
@echo "Run ruff format"
369388
@ruff format $(RUFF_SRC)
389+
ifeq ("$(RUFF_FIXES)","true")
390+
@echo "Run ruff check $(RUFF_FIX_FLAGS)"
391+
@ruff check $(RUFF_FIX_FLAGS) $(RUFF_SRC)
392+
endif
370393

371394
.PHONY: ruff-dirty
372395
ruff-dirty:

0 commit comments

Comments
 (0)