URL: https://github.com/freeipa/freeipa/pull/5741
Author: flo-renaud
 Title: #5741: [Backport][ipa-4-8] pylint: Adapt to new Pylint 2.8
Action: opened

PR body:
"""
This PR was opened automatically because PR #5737 was pushed to master and 
backport to ipa-4-8 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/5741/head:pr5741
git checkout pr5741
From f0b8e2b477b39d2831bd248fa0c6041cf1f27b80 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <s...@altlinux.org>
Date: Sun, 25 Apr 2021 11:22:45 +0300
Subject: [PATCH] pylint: Adapt to new Pylint 2.8

- globally ignore `consider-using-with`
- fix `consider-using-max-builtin`
- explicitly enable pylint on project configuration
- unpin Pylint
- added transformation for IntegrationTest attributes(will work
  unless explicitly defined)

Fixes: https://pagure.io/freeipa/issue/8818
Signed-off-by: Stanislav Levin <s...@altlinux.org>
---
 ipatests/azure/templates/autoconf-fedora.yml  |  1 +
 .../azure/templates/prepare-lint-fedora.yml   |  3 +-
 pylint_plugins.py                             | 82 +++++++++----------
 pylintrc                                      |  3 +
 4 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/ipatests/azure/templates/autoconf-fedora.yml b/ipatests/azure/templates/autoconf-fedora.yml
index df820e44c46..bc8df608c32 100644
--- a/ipatests/azure/templates/autoconf-fedora.yml
+++ b/ipatests/azure/templates/autoconf-fedora.yml
@@ -7,6 +7,7 @@ steps:
     echo "Running autoconf generator"
     ./autogen.sh \
         ${{ parameters.options }} \
+        --enable-pylint \
         --enable-rpmlint \
 
   displayName: Configure the project
diff --git a/ipatests/azure/templates/prepare-lint-fedora.yml b/ipatests/azure/templates/prepare-lint-fedora.yml
index d0e3988b28c..d43eb1c46ec 100644
--- a/ipatests/azure/templates/prepare-lint-fedora.yml
+++ b/ipatests/azure/templates/prepare-lint-fedora.yml
@@ -2,6 +2,5 @@ steps:
 - script: |
     set -e
     sudo dnf -y install python3-pip
-    # https://pagure.io/freeipa/issue/8771
-    python3 -m pip install --user --upgrade astroid pylint==2.7.1
+    python3 -m pip install --user --ignore-installed pylint
   displayName: Install Lint dependencies
diff --git a/pylint_plugins.py b/pylint_plugins.py
index 525a9bee6e4..9bd0419586d 100644
--- a/pylint_plugins.py
+++ b/pylint_plugins.py
@@ -182,50 +182,6 @@ def fake_class(name_or_class_obj, members=()):
         'validatedns',
         'normalizedns',
     ],
-    'ipatests.test_integration.base.IntegrationTest': [
-        {'domain': [
-            {'name': dir(str)},
-        ]},
-        {'master': [
-            {'config': [
-                {'dirman_dn': dir(str)},
-                {'dirman_password': dir(str)},
-                {'admin_password': dir(str)},
-                {'admin_name': dir(str)},
-                {'dns_forwarder': dir(str)},
-                {'test_dir': dir(str)},
-                {'ad_admin_name': dir(str)},
-                {'ad_admin_password': dir(str)},
-                {'domain_level': dir(str)},
-                {'fips_mode': dir(bool)},
-            ]},
-            {'domain': [
-                {'basedn': dir(str)},
-                {'realm': dir(str)},
-                {'name': dir(str)},
-            ]},
-            {'external_hostname': dir(str)},
-            {'hostname': dir(str)},
-            'ip',
-            'collect_log',
-            {'run_command': [
-                {'stdout_text': dir(str)},
-                {'stderr_text': dir(str)},
-                'returncode',
-            ]},
-            {'transport': ['put_file', 'file_exists']},
-            'put_file_contents',
-            'get_file_contents',
-            'ldap_connect',
-            {'spawn_expect': ['__enter__', '__exit__']},
-        ]},
-        'replicas',
-        'clients',
-        'ad_domains',
-        {'ads': dir(list)},
-        {'ad_subdomains': dir(list)},
-        {'ad_treedomains': dir(list)},
-    ]
 }
 
 
@@ -579,3 +535,41 @@ def wildcard(*args, **kwargs):
     dns.rdatatype.URI = 0
     """
 ))
+
+AstroidBuilder(MANAGER).string_build(
+    textwrap.dedent(
+        """\
+    from ipatests.test_integration.base import IntegrationTest
+    from ipatests.pytest_ipa.integration.host import Host, WinHost
+    from ipatests.pytest_ipa.integration.config import Config, Domain
+
+
+    class PylintIPAHosts:
+        def __getitem__(self, key):
+            return Host()
+
+
+    class PylintWinHosts:
+        def __getitem__(self, key):
+            return WinHost()
+
+
+    class PylintADDomains:
+        def __getitem__(self, key):
+            return Domain()
+
+
+    Host.config = Config()
+    Host.domain = Domain()
+
+    IntegrationTest.domain = Domain()
+    IntegrationTest.master = Host()
+    IntegrationTest.replicas = PylintIPAHosts()
+    IntegrationTest.clients = PylintIPAHosts()
+    IntegrationTest.ads = PylintWinHosts()
+    IntegrationTest.ad_treedomains = PylintWinHosts()
+    IntegrationTest.ad_subdomains = PylintWinHosts()
+    IntegrationTest.ad_domains = PylintADDomains()
+    """
+    )
+)
diff --git a/pylintrc b/pylintrc
index 93ddb9dc955..2a82bf87952 100644
--- a/pylintrc
+++ b/pylintrc
@@ -105,6 +105,9 @@ disable=
     f-string-without-interpolation,  # pylint 2.5.0, bare f-strings are ok
     super-with-arguments,  # pylint 2.6.0, zero-length form is syntactic sugar
     raise-missing-from,  # pylint 2.6.0, implicit exception chaining is ok
+    consider-using-with,  # pylint 2.8.0, contextmanager is not mandatory
+    consider-using-max-builtin,  # pylint 2.8.0, can be more readable
+    consider-using-min-builtin,  # pylint 2.8.0, can be more readable
 
 [REPORTS]
 
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to