Skip to content

Commit

Permalink
Merge pull request #1112 from rjeffman/future_pylint
Browse files Browse the repository at this point in the history
Bump linter versions.
  • Loading branch information
t-woerner authored Sep 25, 2023
2 parents fb75aed + 6e1f9f1 commit 12e0d11
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
python-version: "3.x"
- name: Run pylint
run: |
pip install pylint==2.14.4 wrapt==1.14.0
pip install pylint==2.17.2
pylint plugins roles --disable=import-error
shellcheck:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
pass_filenames: true
files: \.(yaml|yml)$
exclude: /env[^/]*.(yaml|yml)$
entry: >-
entry: |-
env
ANSIBLE_LIBRARY=./plugins/modules
ANSIBLE_MODULE_UTILS=./plugins/module_utils
Expand All @@ -21,20 +21,20 @@ repos:
--parseable
--nocolor
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
rev: v1.32.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
- repo: https://github.com/pycqa/flake8
rev: 5.0.3
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
rev: 6.0.0
hooks:
- id: pydocstyle
- repo: https://github.com/pycqa/pylint
rev: v2.14.4
rev: v2.17.2
hooks:
- id: pylint
args:
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaautomountkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ def get_key(self, location, mapname, key):
resp = self.ipa_command("automountkey_show", location, args)
except ipalib_errors.NotFound:
return None
else:
return resp.get("result")
return resp.get("result")

def check_ipa_params(self):
invalid = []
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaautomountlocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def get_location(self, location):
)
except ipalib_errors.NotFound:
return None
else:
return response.get("result", None)
return response.get("result", None)

def check_ipa_params(self):
if len(self.params_get("name")) == 0:
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaautomountmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ def get_automountmap(self, location, name):
)
except Exception: # pylint: disable=broad-except
return None
else:
return response["result"]
return response["result"]

def get_indirect_map_keys(self, location, name):
"""Check if 'name' is an indirect map for 'parentmap'."""
Expand Down
7 changes: 3 additions & 4 deletions plugins/modules/ipaconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ def get_netbios_name(module):
_result = module.ipa_command_no_name("trustconfig_show", {"all": True})
except Exception: # pylint: disable=broad-except
return None
else:
return _result["result"]["ipantflatname"][0]
return _result["result"]["ipantflatname"][0]


def is_enable_sid(module):
Expand Down Expand Up @@ -477,7 +476,7 @@ def main():
params = {}
for x in field_map:
val = ansible_module.params_get(
x, allow_empty_string=(x in allow_empty_string))
x, allow_empty_string=x in allow_empty_string)

if val is not None:
params[field_map.get(x, x)] = val
Expand Down Expand Up @@ -620,7 +619,7 @@ def main():
# boolean values, so we need to convert it to str
# for comparison.
# See: https://github.com/freeipa/freeipa/pull/6294
exit_args[k] = (str(value[0]).upper() == "TRUE")
exit_args[k] = str(value[0]).upper() == "TRUE"
else:
if arg_type not in type_map:
raise ValueError(
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipadelegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ def find_delegation(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if delegation name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(permission, attribute, membergroup, group):
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ipadnsforwardzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def main():
invalid = [
"forwarders", "forwardpolicy", "skip_overlap_check", "permission"
]
wants_enable = (state == "enabled")
wants_enable = state == "enabled"

if operation == "del":
invalid = [
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ipadnsrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ def define_commands_for_present_state(module, zone_name, entry, res_find):
else:
# Create reverse records for existing records
for ipv in ['a', 'aaaa']:
record = ('%srecord' % ipv)
record = '%srecord' % ipv
if record in args and ('%s_extra_create_reverse' % ipv) in args:
cmds = create_reverse_ip_record(
module, zone_name, name, args[record])
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaidrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ def find_idrange(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if idrange name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaidview.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ def find_idview(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if idview name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(description, domain_resolution_order):
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipalocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def find_location(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if location name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(description):
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipapermission.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ def find_permission(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if permission name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(right, attrs, bindtype, subtree,
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaprivilege.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def find_privilege(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if privilege name is not found.
return None
else:
return _result["result"]
return _result["result"]


def main():
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/iparole.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ def find_role(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if role name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(module):
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaselfservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ def find_selfservice(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if selfservice name is not found.
return None
else:
return _result["result"]
return _result["result"]


def gen_args(permission, attribute):
Expand Down
6 changes: 2 additions & 4 deletions plugins/modules/ipaserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ def find_server(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if server name is not found.
return None
else:
return _result["result"]
return _result["result"]


def server_role_status(module, name):
Expand All @@ -218,8 +217,7 @@ def server_role_status(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if server name is not found.
return None
else:
return _result["result"][0]
return _result["result"][0]


def gen_args(location, service_weight, no_members, delete_continue,
Expand Down
14 changes: 7 additions & 7 deletions plugins/modules/ipaservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,15 @@ def gen_args(pac_type, auth_ind, skip_host_check, force, requires_pre_auth,
if auth_ind is not None:
_args['krbprincipalauthind'] = auth_ind
if skip_host_check is not None:
_args['skip_host_check'] = (skip_host_check)
_args['skip_host_check'] = skip_host_check
if force is not None:
_args['force'] = (force)
_args['force'] = force
if requires_pre_auth is not None:
_args['ipakrbrequirespreauth'] = (requires_pre_auth)
_args['ipakrbrequirespreauth'] = requires_pre_auth
if ok_as_delegate is not None:
_args['ipakrbokasdelegate'] = (ok_as_delegate)
_args['ipakrbokasdelegate'] = ok_as_delegate
if ok_to_auth_as_delegate is not None:
_args['ipakrboktoauthasdelegate'] = (ok_to_auth_as_delegate)
_args['ipakrboktoauthasdelegate'] = ok_to_auth_as_delegate

return _args

Expand All @@ -433,9 +433,9 @@ def gen_args_smb(netbiosname, ok_as_delegate, ok_to_auth_as_delegate):
if netbiosname is not None:
_args['ipantflatname'] = netbiosname
if ok_as_delegate is not None:
_args['ipakrbokasdelegate'] = (ok_as_delegate)
_args['ipakrbokasdelegate'] = ok_as_delegate
if ok_to_auth_as_delegate is not None:
_args['ipakrboktoauthasdelegate'] = (ok_to_auth_as_delegate)
_args['ipakrboktoauthasdelegate'] = ok_to_auth_as_delegate

return _args

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaservicedelegationrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def find_servicedelegationrule(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if servicedelegationrule name is not found.
return None
else:
return _result["result"]
return _result["result"]


def check_targets(module, targets):
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipaservicedelegationtarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ def find_servicedelegationtarget(module, name):
except Exception: # pylint: disable=broad-except
# An exception is raised if servicedelegationtarget name is not found.
return None
else:
return _result["result"]
return _result["result"]


def main():
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/ipasudocmdgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ def find_sudocmdgroup(module, name):
_result = module.ipa_command("sudocmdgroup_show", name, args)
except ipalib_errors.NotFound:
return None
else:
return _result["result"]
return _result["result"]


def gen_args(description, nomembers):
Expand Down
4 changes: 3 additions & 1 deletion plugins/modules/ipavault.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,14 @@ def main():
changed = 'Archived data into' in result['summary']
elif command == 'vault_retrieve':
if 'result' not in result:
# pylint: disable=W0012,broad-exception-raised
raise Exception("No result obtained.")
if "data" in result["result"]:
data_return = exit_args.setdefault("vault", {})
data_return["data"] = result["result"]["data"]
else:
if not datafile_out:
# pylint: disable=W0012,broad-exception-raised
raise Exception("No data retrieved.")
changed = False
else:
Expand All @@ -993,7 +995,7 @@ def main():
changed = True
except ipalib_errors.EmptyModlist:
result = {}
except Exception as exception:
except Exception as exception: # pylint: disable=broad-except
ansible_module.fail_json(
msg="%s: %s: %s" % (command, name, str(exception)))

Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-r requirements-tests.txt
ipdb==0.13.4
pre-commit==2.20.0
flake8==5.0.3
flake8-bugbear==22.10.27
pylint==2.14.4
wrapt == 1.14.0
pydocstyle==6.0.0
yamllint==1.28.0
flake8==6.0.0
flake8-bugbear
pylint==2.17.2
wrapt==1.14.1
pydocstyle==6.3.0
yamllint==1.32.0
ansible-lint
3 changes: 1 addition & 2 deletions roles/ipaclient/module_utils/ansible_ipa_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ def configure_nisdomain(_options, domain, _statestore=None):

else:
# IPA version < 4.4

raise Exception("freeipa version '%s' is too old" % VERSION)
raise RuntimeError("freeipa version '%s' is too old" % VERSION)

except ImportError as _err:
ANSIBLE_IPA_CLIENT_MODULE_IMPORT_ERROR = str(_err)
Expand Down
3 changes: 1 addition & 2 deletions roles/ipareplica/module_utils/ansible_ipa_replica.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ def getargspec(func):

else:
# IPA version < 4.6

raise Exception("freeipa version '%s' is too old" % VERSION)
raise RuntimeError("freeipa version '%s' is too old" % VERSION)

except ImportError as _err:
ANSIBLE_IPA_REPLICA_MODULE_IMPORT_ERROR = str(_err)
Expand Down
3 changes: 1 addition & 2 deletions roles/ipaserver/module_utils/ansible_ipa_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ def default_ca_subject_dn(subject_base):

else:
# IPA version < 4.5

raise Exception("freeipa version '%s' is too old" % VERSION)
raise RuntimeError("freeipa version '%s' is too old" % VERSION)

except ImportError as _err:
ANSIBLE_IPA_SERVER_MODULE_IMPORT_ERROR = str(_err)
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ disable =
broad-except,
too-many-branches,
too-many-locals,
fixme
fixme,
use-dict-literal

[pylint.BASIC]
good-names =
Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def set_env_if_not_set(envvar, value):
os.environ[envvar] = value


def pytest_configure(config):
def pytest_configure(config): # pylint: disable=unused-argument
test_dir = os.getenv("TWD")
if not test_dir:
return
Expand Down
Loading

0 comments on commit 12e0d11

Please sign in to comment.