This is an automated email from the ASF dual-hosted git repository.

djwang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new fd7dcfb79a Replace Pylint with Ruff for Python linting
fd7dcfb79a is described below

commit fd7dcfb79a473fcc40635ef61f341531deb04e67
Author: Ed Espino <esp...@apache.org>
AuthorDate: Tue Apr 29 02:45:10 2025 -0700

    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.
---
 gpMgmt/bin/.rcfile                            | 236 --------------------------
 gpMgmt/bin/Makefile                           |  61 ++++---
 gpMgmt/bin/pyproject.toml                     |   5 +
 gpMgmt/bin/pythonSrc/ext/pylint-0.21.0.tar.gz | Bin 199212 -> 0 bytes
 4 files changed, 44 insertions(+), 258 deletions(-)

diff --git a/gpMgmt/bin/.rcfile b/gpMgmt/bin/.rcfile
deleted file mode 100644
index 4d2dbe1935..0000000000
--- a/gpMgmt/bin/.rcfile
+++ /dev/null
@@ -1,236 +0,0 @@
-[COORDINATOR]
-
-# Specify a configuration file.
-#rcfile=
-
-# Python code to execute, usually for sys.path manipulation such as
-# pygtk.require().
-#init-hook=
-
-# Profiled execution.
-profile=no
-
-# Add <file or directory> to the black list. It should be a base name, not a
-# path. You may set this option multiple times.
-ignore=CVS
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-
-[MESSAGES CONTROL]
-
-# Enable the message, report, category or checker with the given id(s). You can
-# either give multiple identifier separated by comma (,) or put this option
-# multiple time.
-#enable=
-
-# Disable the message, report, category or checker with the given id(s). You
-# can either give multiple identifier separated by comma (,) or put this option
-# multiple time.
-#disable=
-
-
-[REPORTS]
-
-# Set the output format. Available formats are text, parseable, colorized, msvs
-# (visual studio) and html
-output-format=text
-
-# Include message's id in output
-include-ids=no
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Tells whether to display a full report or only the messages
-reports=yes
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note). You have access to the variables errors warning, statement which
-# respectively contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (R0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / 
statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (R0004).
-comment=no
-
-
-[BASIC]
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=map,filter,apply,input
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct module level names
-const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct instance attribute names
-attr-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct list comprehension /
-# generator expression variable names
-inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,x,y,z,e,ex,Run,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-no-docstring-rgx=__.*__
-
-
-[FORMAT]
-
-# Maximum number of characters on a single line.
-max-line-length=120
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
-# tab).
-indent-string='    '
-
-
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=FIXME,XXX,TODO
-
-
-[SIMILARITIES]
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
-
-
-[TYPECHECK]
-
-# Tells whether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# List of classes names for which member attributes should not be checked
-# (useful for classes with attributes dynamically set).
-ignored-classes=SQLObject
-
-# When zope mode is activated, add a predefined set of Zope acquired attributes
-# to generated-members.
-zope=no
-
-# List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E0201 when accessed.
-generated-members=REQUEST,acl_users,aq_parent
-
-
-[VARIABLES]
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching names used for dummy variables (i.e. not used).
-dummy-variables-rgx=_|dummy
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
-
-
-[CLASSES]
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,__new__,setUp
-
-
-[DESIGN]
-
-# Maximum number of arguments for function / method
-max-args=5
-
-# Argument names that match this expression will be ignored. Default to name
-# with leading underscore
-ignored-argument-names=_.*
-
-# Maximum number of locals for function / method body
-max-locals=15
-
-# Maximum number of return / yield for function / method body
-max-returns=6
-
-# Maximum number of branch for function / method body
-max-branchs=12
-
-# Maximum number of statements in function / method body
-max-statements=50
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-[IMPORTS]
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report R0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report R0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report R0402 must
-# not be disabled)
-int-import-graph=
diff --git a/gpMgmt/bin/Makefile b/gpMgmt/bin/Makefile
index ba9e18d47e..b61c4faf52 100644
--- a/gpMgmt/bin/Makefile
+++ b/gpMgmt/bin/Makefile
@@ -119,12 +119,8 @@ pyyaml:
        cp -r $(PYLIB_SRC_EXT)/$(PYYAML_DIR)/build/lib*-3*/* $(PYLIB_DIR)/
 
 #
-# PYLINT
+# MOCK SETUP
 #
-
-PYLINT_VERSION=0.21.0
-PYLINT_DIR=pylint-$(PYLINT_VERSION)
-PYLINT_PYTHONPATH=$(PYLIB_DIR):$(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/
 MOCK_VERSION=1.0.1
 MOCK_DIR=mock-$(MOCK_VERSION)
 SETUP_TOOLS_VERSION=36.6.0
@@ -139,12 +135,6 @@ 
PYTHONSRC_INSTALL_PYTHON_PATH=$(PYTHONPATH):$(PYTHONSRC_INSTALL_SITE)
 
MOCK_BIN=$(PYTHONSRC_INSTALL)/lib/python$(PYTHON_VERSION)/site-packages/mock-1.0.1-py2.6.egg
 UBUNTU_PLATFORM=$(shell if lsb_release -a 2>/dev/null | grep -q 'Ubuntu' ; 
then echo "Ubuntu"; fi)
 
-pylint:
-       @echo "--- pylint"
-       @cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PYLINT_DIR).tar.gz
-       @cd $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/ && python3 setup.py build 1> 
/dev/null
-       @touch $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/__init__.py
-
 $(MOCK_BIN):
        @echo "--- mock for platform $(UBUNTU_PLATFORM)"
        @if [ "$(UBUNTU_PLATFORM)" = "Ubuntu" ]; then\
@@ -156,16 +146,43 @@ $(MOCK_BIN):
           PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python3 setup.py install 
--prefix $(PYTHONSRC_INSTALL) ; \
         fi;
 
-PYTHON_FILES=`grep -l --exclude=Makefile --exclude=gplogfilter "/bin/env 
python3" *`\
-                        `grep -l "/bin/env python3" $(SRC)/../sbin/*`\
-                        `find ./gppylib -name "*.py"`\
-                        `find $(SRC)/../sbin -name "*.py"`
-
-checkcode: pylint
-       @echo "Running pylint on management scripts..."
-       @PYTHONPATH=$(PYTHONPATH):$(PYLINT_PYTHONPATH) 
$(PYLIB_SRC_EXT)/$(PYLINT_DIR)/bin/pylint -i y $(PYTHON_FILES) --rcfile=.rcfile 
> $(SRC)/../pylint.txt || true
-       @echo -n "pylint_score=" > $(SRC)/../pylint_score.properties
-       @grep "Your code has been rated at" $(SRC)/../pylint.txt | sed -e 
"s|Your .* \(.*\)/.*|\1|" >> $(SRC)/../pylint_score.properties
+# -----------------------------------------------------------------------------
+#
+# Ruff installation
+#
+# We dynamically retrieve the latest Ruff binary using the official install 
script.
+# No tarballs or source files for Ruff are stored in this repository.
+# This simplifies maintenance and ensures the linter is up-to-date.
+#
+# Note: Internet access is required for the initial installation.
+# -----------------------------------------------------------------------------
+RUFF_INSTALL_DIR ?= $(HOME)/.local/bin
+RUFF_BIN=$(RUFF_INSTALL_DIR)/ruff
+
+ruff:
+       @if [ ! -x "$(RUFF_BIN)" ]; then \
+               echo "--- Installing ruff linter"; \
+               mkdir -p $(RUFF_INSTALL_DIR); \
+               curl -LsSf https://astral.sh/ruff/install.sh | 
BIN_DIR=$(RUFF_INSTALL_DIR) sh; \
+               echo "--- ruff installed at $(RUFF_BIN)"; \
+       else \
+               echo "--- ruff already installed at $(RUFF_BIN)"; \
+       fi
+       @$(RUFF_BIN) --version
+
+PYTHON_FILES=`grep -l --exclude=Makefile \
+                     --exclude=ruff.txt \
+                     --exclude=gplogfilter \
+                     "/bin/env python3" *`\
+             `grep -l "/bin/env python3" \
+                      $(SRC)/../sbin/*`\
+             `find ./gppylib -name "*.py"`\
+             `find $(SRC)/../sbin -name "*.py"`
+
+checkcode: ruff
+       @echo "Running ruff on management scripts..."
+       @RUST_LOG=error $(RUFF_BIN) check -v $(PYTHON_FILES) > $(SRC)/ruff.txt 
|| true
+       @echo "Ruff lint completed. Results saved to $(SRC)/ruff.txt"
 
 check: $(MOCK_BIN)
        @echo "Running pure unit and also "unit" tests that require cluster to 
be up..."
@@ -189,7 +206,7 @@ installcheck: installcheck-bash
        $(MAKE) -C gpload_test $@
 
 clean distclean:
-       rm -rf $(PYLIB_SRC_EXT)/$(PYLINT_DIR)
+       rm -rf $(RUFF_BIN) $(SRC)/ruff.txt $(SRC)/.ruff_cache
        rm -rf $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/build
        rm -rf $(PYLIB_SRC)/$(PYGRESQL_DIR)/build
        rm -rf *.pyc
diff --git a/gpMgmt/bin/pyproject.toml b/gpMgmt/bin/pyproject.toml
new file mode 100644
index 0000000000..ae5c1113e8
--- /dev/null
+++ b/gpMgmt/bin/pyproject.toml
@@ -0,0 +1,5 @@
+[tool.ruff]
+line-length = 88
+
+[tool.ruff.lint]
+select = ["E", "F", "W"]
diff --git a/gpMgmt/bin/pythonSrc/ext/pylint-0.21.0.tar.gz 
b/gpMgmt/bin/pythonSrc/ext/pylint-0.21.0.tar.gz
deleted file mode 100644
index cf876d3331..0000000000
Binary files a/gpMgmt/bin/pythonSrc/ext/pylint-0.21.0.tar.gz and /dev/null 
differ


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org
For additional commands, e-mail: commits-h...@cloudberry.apache.org

Reply via email to