Skip to content

Commit 4395c0e

Browse files
committed
Replace pylint with ruff for Python linting
As discussed in the community, the `pylint` package is licensed under GPL, which falls under Category X and is not allowed to be bundled with Apache software. To comply with licensing requirements, we are replacing `pylint` with `ruff`, an alternative Python linter that is licensed under MIT. This PR removes `pylint` usage and integrates `ruff` for Python code linting. See #961
1 parent b1cf523 commit 4395c0e

File tree

5 files changed

+1416
-15
lines changed

5 files changed

+1416
-15
lines changed

LICENSE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ The PostgreSQL software includes:
260260
gpMgmt/bin/pythonSrc/ext/parse-1.8.2.tar.gz
261261
see licenses/LICENSE-parse.txt
262262

263+
gpMgmt/bin/pythonSrc/ext/ruff-0.11.5.tar.gz
264+
see licenses/LICENSE-ruff.txt
265+
263266
----------------------------
264267
Internet Systems Consortium/Internet Software Consortium (ISC) LICENSE
265268

gpMgmt/bin/Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ pyyaml:
119119
cp -r $(PYLIB_SRC_EXT)/$(PYYAML_DIR)/build/lib*-3*/* $(PYLIB_DIR)/
120120

121121
#
122-
# PYLINT
122+
# RUFF
123123
#
124124

125-
PYLINT_VERSION=0.21.0
126-
PYLINT_DIR=pylint-$(PYLINT_VERSION)
127-
PYLINT_PYTHONPATH=$(PYLIB_DIR):$(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/
125+
RUFF_VERSION=0.11.5
126+
RUFF_DIR=ruff-$(RUFF_VERSION)
127+
RUFF_PYTHONPATH=$(PYLIB_DIR):$(PYLIB_SRC_EXT)/$(RUFF_DIR)/build/lib/
128128
MOCK_VERSION=1.0.1
129129
MOCK_DIR=mock-$(MOCK_VERSION)
130130
SETUP_TOOLS_VERSION=36.6.0
@@ -139,11 +139,11 @@ PYTHONSRC_INSTALL_PYTHON_PATH=$(PYTHONPATH):$(PYTHONSRC_INSTALL_SITE)
139139
MOCK_BIN=$(PYTHONSRC_INSTALL)/lib/python$(PYTHON_VERSION)/site-packages/mock-1.0.1-py2.6.egg
140140
UBUNTU_PLATFORM=$(shell if lsb_release -a 2>/dev/null | grep -q 'Ubuntu' ; then echo "Ubuntu"; fi)
141141

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
142+
ruff:
143+
@echo "--- ruff"
144+
@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(RUFF_DIR).tar.gz
145+
@cd $(PYLIB_SRC_EXT)/$(RUFF_DIR)/ && python3 setup.py build 1> /dev/null
146+
@touch $(PYLIB_SRC_EXT)/$(RUFF_DIR)/build/lib/__init__.py
147147

148148
$(MOCK_BIN):
149149
@echo "--- mock for platform $(UBUNTU_PLATFORM)"
@@ -161,11 +161,11 @@ PYTHON_FILES=`grep -l --exclude=Makefile --exclude=gplogfilter "/bin/env python3
161161
`find ./gppylib -name "*.py"`\
162162
`find $(SRC)/../sbin -name "*.py"`
163163

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
164+
checkcode: ruff
165+
@echo "Running ruff on management scripts..."
166+
@PYTHONPATH=$(PYTHONPATH):$(RUFF_PYTHONPATH) $(PYLIB_SRC_EXT)/$(RUFF_DIR)/bin/ruff check $(PYTHON_FILES) --config .rcfile > $(SRC)/../ruff.txt || true
167+
@echo -n "ruff_check_status=" > $(SRC)/../ruff_status.properties
168+
@grep "Your code has been checked at" $(SRC)/../ruff.txt | sed -e "s|Your .* \(.*\)/.*|\1|" >> $(SRC)/../ruff_status.properties
169169

170170
check: $(MOCK_BIN)
171171
@echo "Running pure unit and also "unit" tests that require cluster to be up..."
@@ -189,7 +189,7 @@ installcheck: installcheck-bash
189189
$(MAKE) -C gpload_test $@
190190

191191
clean distclean:
192-
rm -rf $(PYLIB_SRC_EXT)/$(PYLINT_DIR)
192+
rm -rf $(PYLIB_SRC_EXT)/$(RUFF_DIR)
193193
rm -rf $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/build
194194
rm -rf $(PYLIB_SRC)/$(PYGRESQL_DIR)/build
195195
rm -rf *.pyc
-195 KB
Binary file not shown.
3.79 MB
Binary file not shown.

0 commit comments

Comments
 (0)