https://github.com/python/cpython/commit/cc6839a1810290e483e5d5f0786d9b46c4294d47
commit: cc6839a1810290e483e5d5f0786d9b46c4294d47
branch: main
author: Adam Turner <9087854+aa-tur...@users.noreply.github.com>
committer: AA-Turner <9087854+aa-tur...@users.noreply.github.com>
date: 2024-08-03T12:52:21+01:00
summary:

GH-109408: Stop running patchcheck in CI (#109895)

files:
M .azure-pipelines/posix-steps.yml
M .azure-pipelines/pr.yml
M Tools/patchcheck/patchcheck.py

diff --git a/.azure-pipelines/posix-steps.yml b/.azure-pipelines/posix-steps.yml
index e23c7b1dcb55c1..99fb7f3b1105b6 100644
--- a/.azure-pipelines/posix-steps.yml
+++ b/.azure-pipelines/posix-steps.yml
@@ -18,9 +18,3 @@ steps:
 
 - script: make pythoninfo
   displayName: 'Display build info'
-
-- script: |
-    git fetch origin
-    ./python Tools/patchcheck/patchcheck.py --ci true
-  displayName: 'Run patchcheck.py'
-  condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
diff --git a/.azure-pipelines/pr.yml b/.azure-pipelines/pr.yml
index 335a4b407cb83c..433396778ab891 100644
--- a/.azure-pipelines/pr.yml
+++ b/.azure-pipelines/pr.yml
@@ -9,20 +9,3 @@ jobs:
 
   steps:
   - template: ./prebuild-checks.yml
-
-
-- job: Ubuntu_Patchcheck
-  displayName: Ubuntu patchcheck
-  dependsOn: Prebuild
-  condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 
'true'))
-
-  pool:
-    vmImage: ubuntu-22.04
-
-  variables:
-    testRunTitle: '$(system.pullRequest.TargetBranch)-linux'
-    testRunPlatform: linux
-    openssl_version: 1.1.1u
-
-  steps:
-  - template: ./posix-steps.yml
diff --git a/Tools/patchcheck/patchcheck.py b/Tools/patchcheck/patchcheck.py
index fc338f389ca6d9..0dcf6ef844a048 100755
--- a/Tools/patchcheck/patchcheck.py
+++ b/Tools/patchcheck/patchcheck.py
@@ -5,9 +5,6 @@
 import subprocess
 import sysconfig
 
-import reindent
-import untabify
-
 
 def get_python_source_dir():
     src_dir = sysconfig.get_config_var('abs_srcdir')
@@ -16,13 +13,6 @@ def get_python_source_dir():
     return os.path.abspath(src_dir)
 
 
-# Excluded directories which are copies of external libraries:
-# don't check their coding style
-EXCLUDE_DIRS = [
-    os.path.join('Modules', '_decimal', 'libmpdec'),
-    os.path.join('Modules', 'expat'),
-    os.path.join('Modules', 'zlib'),
-    ]
 SRCDIR = get_python_source_dir()
 
 
@@ -153,62 +143,7 @@ def changed_files(base_branch=None):
     else:
         sys.exit('need a git checkout to get modified files')
 
-    filenames2 = []
-    for filename in filenames:
-        # Normalize the path to be able to match using .startswith()
-        filename = os.path.normpath(filename)
-        if any(filename.startswith(path) for path in EXCLUDE_DIRS):
-            # Exclude the file
-            continue
-        filenames2.append(filename)
-
-    return filenames2
-
-
-def report_modified_files(file_paths):
-    count = len(file_paths)
-    if count == 0:
-        return n_files_str(count)
-    else:
-        lines = [f"{n_files_str(count)}:"]
-        for path in file_paths:
-            lines.append(f"  {path}")
-        return "\n".join(lines)
-
-
-#: Python files that have tabs by design:
-_PYTHON_FILES_WITH_TABS = frozenset({
-    'Tools/c-analyzer/cpython/_parser.py',
-})
-
-
-@status("Fixing Python file whitespace", info=report_modified_files)
-def normalize_whitespace(file_paths):
-    """Make sure that the whitespace for .py files have been normalized."""
-    reindent.makebackup = False  # No need to create backups.
-    fixed = [
-        path for path in file_paths
-        if (
-            path.endswith('.py')
-            and path not in _PYTHON_FILES_WITH_TABS
-            and reindent.check(os.path.join(SRCDIR, path))
-        )
-    ]
-    return fixed
-
-
-@status("Fixing C file whitespace", info=report_modified_files)
-def normalize_c_whitespace(file_paths):
-    """Report if any C files """
-    fixed = []
-    for path in file_paths:
-        abspath = os.path.join(SRCDIR, path)
-        with open(abspath, 'r') as f:
-            if '\t' not in f.read():
-                continue
-        untabify.process(abspath, 8, verbose=False)
-        fixed.append(path)
-    return fixed
+    return list(map(os.path.normpath, filenames))
 
 
 @status("Docs modified", modal=True)
@@ -248,40 +183,14 @@ def regenerated_pyconfig_h_in(file_paths):
         return "not needed"
 
 
-def ci(pull_request):
-    if pull_request == 'false':
-        print('Not a pull request; skipping')
-        return
-    base_branch = get_base_branch()
-    file_paths = changed_files(base_branch)
-    python_files = [fn for fn in file_paths if fn.endswith('.py')]
-    c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))]
-    fixed = []
-    fixed.extend(normalize_whitespace(python_files))
-    fixed.extend(normalize_c_whitespace(c_files))
-    if not fixed:
-        print('No whitespace issues found')
-    else:
-        count = len(fixed)
-        print(f'Please fix the {n_files_str(count)} with whitespace issues')
-        print('(on Unix you can run `make patchcheck` to make the fixes)')
-        sys.exit(1)
-
-
 def main():
     base_branch = get_base_branch()
     file_paths = changed_files(base_branch)
-    python_files = [fn for fn in file_paths if fn.endswith('.py')]
-    c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))]
-    doc_files = [fn for fn in file_paths if fn.startswith('Doc') and
-                 fn.endswith(('.rst', '.inc'))]
+    has_doc_files = any(fn for fn in file_paths if fn.startswith('Doc') and
+                        fn.endswith(('.rst', '.inc')))
     misc_files = {p for p in file_paths if p.startswith('Misc')}
-    # PEP 8 whitespace rules enforcement.
-    normalize_whitespace(python_files)
-    # C rules enforcement.
-    normalize_c_whitespace(c_files)
     # Docs updated.
-    docs_modified(doc_files)
+    docs_modified(has_doc_files)
     # Misc/ACKS changed.
     credit_given(misc_files)
     # Misc/NEWS changed.
@@ -292,19 +201,14 @@ def main():
     regenerated_pyconfig_h_in(file_paths)
 
     # Test suite run and passed.
-    if python_files or c_files:
-        end = " and check for refleaks?" if c_files else "?"
-        print()
-        print("Did you run the test suite" + end)
+    has_c_files = any(fn for fn in file_paths if fn.endswith(('.c', '.h')))
+    has_python_files = any(fn for fn in file_paths if fn.endswith('.py'))
+    print()
+    if has_c_files:
+        print("Did you run the test suite and check for refleaks?")
+    elif has_python_files:
+        print("Did you run the test suite?")
 
 
 if __name__ == '__main__':
-    import argparse
-    parser = argparse.ArgumentParser(description=__doc__)
-    parser.add_argument('--ci',
-                        help='Perform pass/fail checks')
-    args = parser.parse_args()
-    if args.ci:
-        ci(args.ci)
-    else:
-        main()
+    main()

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to