You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2023/03/10 22:02:17 UTC

[allura] 02/03: [#8502] remove old unused pylint custom check

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

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit cedea1b40fc4efc4a939f4b6828bfde41cb27ab3
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Fri Mar 10 16:20:42 2023 -0500

    [#8502] remove old unused pylint custom check
---
 AlluraTest/alluratest/pylint_checkers.py | 73 --------------------------------
 AlluraTest/alluratest/test_syntax.py     | 10 -----
 requirements.in                          |  1 -
 3 files changed, 84 deletions(-)

diff --git a/AlluraTest/alluratest/pylint_checkers.py b/AlluraTest/alluratest/pylint_checkers.py
deleted file mode 100644
index fa2766ff2..000000000
--- a/AlluraTest/alluratest/pylint_checkers.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-import astroid
-
-from pylint.checkers import BaseChecker, utils
-from pylint.interfaces import IAstroidChecker
-
-
-def register(linter):
-    linter.register_checker(ExposedAPIHasKwargs(linter))
-
-
-# FIXME?
-BASE_ID = 76  # taken from https://github.com/edx/edx-lint/tree/master/edx_lint/pylint
-
-class ExposedAPIHasKwargs(BaseChecker):
-
-    __implements__ = (IAstroidChecker,)
-
-    name = 'exposed-api-needs-kwargs'
-
-    MESSAGE_ID = name
-    msgs = {
-        'E%d10' % BASE_ID: (
-            "@expose'd method %s() looks like an API and needs **kwargs",
-            MESSAGE_ID,
-            "@expose'd API methods should have **kwargs to avoid an error when accessed with ?access_token=XYZ",
-        ),
-    }
-
-    @utils.check_messages(MESSAGE_ID)
-    def visit_function(self, node):
-        # special TurboGears method name, doesn't need **kw
-        if node.name == '_lookup':
-            return
-
-        # Assume @expose('json:') means its an API endpoint.  Not a perfect assumption:
-        #  - could be an API endpoint used only for PUT/POST with no json result)
-        #  - there are non-API endpoints that return json (for ajax)
-        has_json_expose = False
-        if node.decorators:
-            for dec in node.decorators.nodes:
-                if hasattr(dec, 'func'):  # otherwise its a @deco without parens
-                    if getattr(dec.func, 'name', '') == 'expose':
-                        for arg in dec.args:
-                            if getattr(arg, 'value', '') in ('json', 'json:'):
-                                has_json_expose = True
-
-        if not has_json_expose:
-            return
-
-        if node.args.kwarg:
-            return
-
-        if not self.linter.is_message_enabled(self.MESSAGE_ID, line=node.fromlineno):
-            return
-
-        self.add_message(self.MESSAGE_ID, args=node.name, node=node)
diff --git a/AlluraTest/alluratest/test_syntax.py b/AlluraTest/alluratest/test_syntax.py
index da40861de..6bf68f3f1 100644
--- a/AlluraTest/alluratest/test_syntax.py
+++ b/AlluraTest/alluratest/test_syntax.py
@@ -71,12 +71,6 @@ def test_no_tabs():
         raise Exception('These should not use tab chars')
 
 
-def run_linter(files):
-    raise SkipTest('pylint see [#8346]')
-    if run('pylint -E --disable=all --enable=exposed-api-needs-kwargs --load-plugins alluratest.pylint_checkers {}'.format(' '.join(files))) != 0:
-        raise Exception('Custom Allura pylint errors found.')
-
-
 def run_ruff(files):
     # skip some that aren't critical errors
     files = [f for f in files if '/migrations/' not in f]
@@ -108,10 +102,6 @@ def create_many_lint_methods():
         if not files:
             continue
 
-        lint_test_method = lambda self, these_files=files: run_linter(these_files)
-        lint_test_method.__name__ = str(f'test_pylint_{i}')
-        setattr(TestLinters, f'test_pylint_{i}', lint_test_method)
-
         pyflake_test_method = lambda self, these_files=files: run_ruff(these_files)
         pyflake_test_method.__name__ = str(f'test_ruff_{i}')
         setattr(TestLinters, f'test_ruff_{i}', pyflake_test_method)
diff --git a/requirements.in b/requirements.in
index e209b3487..0644bdfdb 100644
--- a/requirements.in
+++ b/requirements.in
@@ -50,7 +50,6 @@ wrapt
 # testing
 mock
 ruff
-#pylint -- disabled due to [#8346]  (also requires diff versions on py2 vs 3, including transitive deps which gets tricky with pip-compile)
 testfixtures
 WebTest
 pytest