Skip to content

Commit 1e23303

Browse files
committed
Replace Pylint with Ruff for Python linting
- Remove Pylint installation, configuration, and invocation from the Makefile. - Remove the GPL-licensed tarball: gpMgmt/bin/pythonSrc/ext/pylint-0.21.0.tar.gz - Remove the old Pylint configuration file (.rcfile) since it is no longer relevant. - Introduce Ruff installation via the official installation script. - Dynamically install Ruff instead of storing tarballs or source files. - Update checkcode target to run Ruff instead of Pylint. - Clean up references to Pylint tarballs in the clean/distclean target. - Add new pyproject.toml file to configure Ruff: [tool.ruff] line-length = 88 [tool.ruff.lint] select = ["E", "F", "W"] Note: Ruff installation requires internet access during the first run. Note: The removal of the Pylint .rcfile requires eventual replacement with corresponding Ruff configuration enhancements if more complex rules are needed in the future. This change only introduces Ruff into the workflow. It does not attempt to fix or address any issues that Ruff may report.
1 parent 41f32d9 commit 1e23303

File tree

4 files changed

+44
-258
lines changed

4 files changed

+44
-258
lines changed

gpMgmt/bin/.rcfile

-236
This file was deleted.

gpMgmt/bin/Makefile

+39-22
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,8 @@ pyyaml:
119119
cp -r $(PYLIB_SRC_EXT)/$(PYYAML_DIR)/build/lib*-3*/* $(PYLIB_DIR)/
120120

121121
#
122-
# PYLINT
122+
# MOCK SETUP
123123
#
124-
125-
PYLINT_VERSION=0.21.0
126-
PYLINT_DIR=pylint-$(PYLINT_VERSION)
127-
PYLINT_PYTHONPATH=$(PYLIB_DIR):$(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/
128124
MOCK_VERSION=1.0.1
129125
MOCK_DIR=mock-$(MOCK_VERSION)
130126
SETUP_TOOLS_VERSION=36.6.0
@@ -139,12 +135,6 @@ PYTHONSRC_INSTALL_PYTHON_PATH=$(PYTHONPATH):$(PYTHONSRC_INSTALL_SITE)
139135
MOCK_BIN=$(PYTHONSRC_INSTALL)/lib/python$(PYTHON_VERSION)/site-packages/mock-1.0.1-py2.6.egg
140136
UBUNTU_PLATFORM=$(shell if lsb_release -a 2>/dev/null | grep -q 'Ubuntu' ; then echo "Ubuntu"; fi)
141137

142-
pylint:
143-
@echo "--- pylint"
144-
@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PYLINT_DIR).tar.gz
145-
@cd $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/ && python3 setup.py build 1> /dev/null
146-
@touch $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/__init__.py
147-
148138
$(MOCK_BIN):
149139
@echo "--- mock for platform $(UBUNTU_PLATFORM)"
150140
@if [ "$(UBUNTU_PLATFORM)" = "Ubuntu" ]; then\
@@ -156,16 +146,43 @@ $(MOCK_BIN):
156146
PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python3 setup.py install --prefix $(PYTHONSRC_INSTALL) ; \
157147
fi;
158148

159-
PYTHON_FILES=`grep -l --exclude=Makefile --exclude=gplogfilter "/bin/env python3" *`\
160-
`grep -l "/bin/env python3" $(SRC)/../sbin/*`\
161-
`find ./gppylib -name "*.py"`\
162-
`find $(SRC)/../sbin -name "*.py"`
163-
164-
checkcode: pylint
165-
@echo "Running pylint on management scripts..."
166-
@PYTHONPATH=$(PYTHONPATH):$(PYLINT_PYTHONPATH) $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/bin/pylint -i y $(PYTHON_FILES) --rcfile=.rcfile > $(SRC)/../pylint.txt || true
167-
@echo -n "pylint_score=" > $(SRC)/../pylint_score.properties
168-
@grep "Your code has been rated at" $(SRC)/../pylint.txt | sed -e "s|Your .* \(.*\)/.*|\1|" >> $(SRC)/../pylint_score.properties
149+
# -----------------------------------------------------------------------------
150+
#
151+
# Ruff installation
152+
#
153+
# We dynamically retrieve the latest Ruff binary using the official install script.
154+
# No tarballs or source files for Ruff are stored in this repository.
155+
# This simplifies maintenance and ensures the linter is up-to-date.
156+
#
157+
# Note: Internet access is required for the initial installation.
158+
# -----------------------------------------------------------------------------
159+
RUFF_INSTALL_DIR ?= $(HOME)/.local/bin
160+
RUFF_BIN=$(RUFF_INSTALL_DIR)/ruff
161+
162+
ruff:
163+
@if [ ! -x "$(RUFF_BIN)" ]; then \
164+
echo "--- Installing ruff linter"; \
165+
mkdir -p $(RUFF_INSTALL_DIR); \
166+
curl -LsSf https://astral.sh/ruff/install.sh | BIN_DIR=$(RUFF_INSTALL_DIR) sh; \
167+
echo "--- ruff installed at $(RUFF_BIN)"; \
168+
else \
169+
echo "--- ruff already installed at $(RUFF_BIN)"; \
170+
fi
171+
@$(RUFF_BIN) --version
172+
173+
PYTHON_FILES=`grep -l --exclude=Makefile \
174+
--exclude=ruff.txt \
175+
--exclude=gplogfilter \
176+
"/bin/env python3" *`\
177+
`grep -l "/bin/env python3" \
178+
$(SRC)/../sbin/*`\
179+
`find ./gppylib -name "*.py"`\
180+
`find $(SRC)/../sbin -name "*.py"`
181+
182+
checkcode: ruff
183+
@echo "Running ruff on management scripts..."
184+
@RUST_LOG=error $(RUFF_BIN) check -v $(PYTHON_FILES) > $(SRC)/ruff.txt || true
185+
@echo "Ruff lint completed. Results saved to $(SRC)/ruff.txt"
169186

170187
check: $(MOCK_BIN)
171188
@echo "Running pure unit and also "unit" tests that require cluster to be up..."
@@ -189,7 +206,7 @@ installcheck: installcheck-bash
189206
$(MAKE) -C gpload_test $@
190207

191208
clean distclean:
192-
rm -rf $(PYLIB_SRC_EXT)/$(PYLINT_DIR)
209+
rm -rf $(RUFF_BIN) $(SRC)/ruff.txt $(SRC)/.ruff_cache
193210
rm -rf $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/build
194211
rm -rf $(PYLIB_SRC)/$(PYGRESQL_DIR)/build
195212
rm -rf *.pyc

gpMgmt/bin/pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[tool.ruff]
2+
line-length = 88
3+
4+
[tool.ruff.lint]
5+
select = ["E", "F", "W"]
-195 KB
Binary file not shown.

0 commit comments

Comments
 (0)