From 29debd2be650c860b4125395b01c319a5630d3e7 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 7 Apr 2022 03:06:28 -0700 Subject: [PATCH 1/8] Add a skips for pre-commit.ci (#161) --- .pre-commit-config.yaml | 7 +++++++ changelogs/fragments/pre-commit-skip.yml | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 changelogs/fragments/pre-commit-skip.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a3cc65..9b57f1b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,11 @@ --- +ci: + skip: + # pre-commit.ci has trouble with this one + - update-docs + - black + - end-of-file-fixer + - trailing-whitespace repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.1.0 diff --git a/changelogs/fragments/pre-commit-skip.yml b/changelogs/fragments/pre-commit-skip.yml new file mode 100644 index 0000000..efe85b1 --- /dev/null +++ b/changelogs/fragments/pre-commit-skip.yml @@ -0,0 +1,6 @@ +--- +trivial: + - Exempt update-docs from pre-commit.ci + - Disable black temporarily until it can be upgraded + - Disable end-of-file-fixer + - Disable trailing-whitespace From 35c0cdde4c7bba062d0dff532b0d902b6e11c32b Mon Sep 17 00:00:00 2001 From: cidrblock Date: Wed, 6 Apr 2022 07:50:47 -0700 Subject: [PATCH 2/8] Update black to latest --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b57f1b..d8882be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: args: [--branch, main] - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 19.3b0 + rev: 22.3.0 hooks: - id: black args: [-l, "79"] From 994792defd5b1fec455440704dd6d9295be4932c Mon Sep 17 00:00:00 2001 From: cidrblock Date: Wed, 6 Apr 2022 08:06:27 -0700 Subject: [PATCH 3/8] No update docs --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8882be..d9be52c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,5 @@ --- +<<<<<<< HEAD ci: skip: # pre-commit.ci has trouble with this one @@ -6,6 +7,13 @@ ci: - black - end-of-file-fixer - trailing-whitespace +||||||| parent of 681ca40 (No update docs) +======= +ci: + skip: + # pre-commit.ci has trouble with this one + - update-docs +>>>>>>> 681ca40 (No update docs) repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.1.0 From 0c79ad75b09eb7bb9a5f1ee1e0505cb7bb3967d7 Mon Sep 17 00:00:00 2001 From: cidrblock Date: Wed, 6 Apr 2022 08:11:52 -0700 Subject: [PATCH 4/8] Add changelog --- changelogs/fragments/pre-commit-updates.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelogs/fragments/pre-commit-updates.yml diff --git a/changelogs/fragments/pre-commit-updates.yml b/changelogs/fragments/pre-commit-updates.yml new file mode 100644 index 0000000..40d1c8a --- /dev/null +++ b/changelogs/fragments/pre-commit-updates.yml @@ -0,0 +1,4 @@ +--- +trivial: + - Update black version to latest + - Exempt update-docs from pre-commit.ci \ No newline at end of file From b54230531ee5497f09bc8dea7330cdcc679d870c Mon Sep 17 00:00:00 2001 From: cidrblock Date: Wed, 6 Apr 2022 08:28:04 -0700 Subject: [PATCH 5/8] update black in test-requirements --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 8958f9f..f97d3d1 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -black==19.3b0 ; python_version > '3.5' +black==22.3.0 ; python_version > '3.5' coverage==4.5.4 flake8 ipaddress ; python_version < '3.0' From c4ad14f3058011ad98e56a4ae09649fdeebc82b1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 15:30:29 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelogs/fragments/pre-commit-updates.yml | 2 +- plugins/filter/cidr_merge.py | 3 +- plugins/filter/from_xml.py | 2 +- plugins/filter/get_path.py | 2 +- plugins/filter/hwaddr.py | 7 +- plugins/filter/index_of.py | 2 +- plugins/filter/ip4_hex.py | 7 +- plugins/filter/ipaddr.py | 5 +- plugins/filter/ipmath.py | 5 +- plugins/filter/ipsubnet.py | 7 +- plugins/filter/ipv4.py | 5 +- plugins/filter/ipv6.py | 5 +- plugins/filter/ipwrap.py | 5 +- plugins/filter/macaddr.py | 7 +- plugins/filter/network_in_network.py | 5 +- plugins/filter/network_in_usable.py | 5 +- plugins/filter/next_nth_usable.py | 5 +- plugins/filter/nthhost.py | 7 +- plugins/filter/param_list_compare.py | 2 +- plugins/filter/previous_nth_usable.py | 5 +- plugins/filter/reduce_on_network.py | 5 +- plugins/filter/slaac.py | 7 +- plugins/filter/to_paths.py | 2 +- plugins/filter/to_xml.py | 2 +- plugins/filter/usable_range.py | 2 +- plugins/plugin_utils/base/cli_parser.py | 2 +- plugins/plugin_utils/base/ipaddr_utils.py | 4 +- plugins/plugin_utils/base/ipaddress_utils.py | 9 +- plugins/plugin_utils/base/utils.py | 3 +- plugins/sub_plugins/cli_parser/json_parser.py | 4 +- .../sub_plugins/cli_parser/textfsm_parser.py | 6 +- plugins/sub_plugins/cli_parser/ttp_parser.py | 6 +- plugins/sub_plugins/cli_parser/xml_parser.py | 7 +- plugins/sub_plugins/validate/jsonschema.py | 8 +- plugins/test/in_any_network.py | 2 +- plugins/test/in_network.py | 2 +- plugins/test/in_one_network.py | 2 +- plugins/test/ip.py | 4 +- plugins/test/ip_address.py | 2 +- plugins/test/ipv4.py | 2 +- plugins/test/ipv4_address.py | 2 +- plugins/test/ipv4_hostmask.py | 2 +- plugins/test/ipv4_netmask.py | 4 +- plugins/test/ipv6.py | 2 +- plugins/test/ipv6_address.py | 2 +- plugins/test/ipv6_ipv4_mapped.py | 4 +- plugins/test/ipv6_sixtofour.py | 4 +- plugins/test/ipv6_teredo.py | 4 +- plugins/test/loopback.py | 4 +- plugins/test/mac.py | 4 +- plugins/test/multicast.py | 4 +- plugins/test/private.py | 4 +- plugins/test/public.py | 4 +- plugins/test/reserved.py | 4 +- plugins/test/resolvable.py | 4 +- plugins/test/subnet_of.py | 4 +- plugins/test/supernet_of.py | 4 +- plugins/test/unspecified.py | 4 +- .../files/nxos_show_version.txt | 2 +- .../output/nxos_show_interface_json_text.txt | 2 +- .../nxos_show_interface_ttp_parsed.json | 2 +- .../templates/centos_df_-h.ttp | 2 +- .../templates/centos_ifconfig.textfsm | 2 +- .../templates/fedora_df_-h.ttp | 2 +- .../templates/fedora_ifconfig.textfsm | 2 +- .../templates/ubuntu_df_-h.ttp | 2 +- .../templates/ubuntu_ifconfig.textfsm | 2 +- .../utils_ipaddr_filter/vars/main.yaml | 2 +- .../files/criteria/check_list_data.json | 2 +- .../files/criteria/crc_error_check.json | 2 +- .../files/criteria/enabled_check.json | 2 +- .../files/criteria/in_rate_check.json | 2 +- .../files/criteria/oper_status_up.json | 2 +- tests/unit/module_utils/fixtures/large.json | 2 +- .../action/fixtures/nxos_show_version.txt | 2 +- tests/unit/plugins/action/test_cli_parse.py | 100 +++++++----------- tests/unit/plugins/filter/test_ipmath.py | 2 +- .../fixtures/nxos_show_version.cfg | 12 +-- .../fixtures/nxos_show_version.ttp | 2 +- .../sub_plugins/validate/test_config.py | 6 +- 80 files changed, 174 insertions(+), 220 deletions(-) diff --git a/changelogs/fragments/pre-commit-updates.yml b/changelogs/fragments/pre-commit-updates.yml index 40d1c8a..8a06961 100644 --- a/changelogs/fragments/pre-commit-updates.yml +++ b/changelogs/fragments/pre-commit-updates.yml @@ -1,4 +1,4 @@ --- trivial: - Update black version to latest - - Exempt update-docs from pre-commit.ci \ No newline at end of file + - Exempt update-docs from pre-commit.ci diff --git a/plugins/filter/cidr_merge.py b/plugins/filter/cidr_merge.py index ef4dc74..e4bfd85 100644 --- a/plugins/filter/cidr_merge.py +++ b/plugins/filter/cidr_merge.py @@ -177,8 +177,7 @@ def cidr_merge(value, action="merge"): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks diff --git a/plugins/filter/from_xml.py b/plugins/filter/from_xml.py index b423234..e805ac4 100644 --- a/plugins/filter/from_xml.py +++ b/plugins/filter/from_xml.py @@ -141,7 +141,7 @@ def _from_xml(*args, **kwargs): class FilterModule(object): - """ from_xml """ + """from_xml""" def filters(self): diff --git a/plugins/filter/get_path.py b/plugins/filter/get_path.py index 97a67e6..88d2715 100644 --- a/plugins/filter/get_path.py +++ b/plugins/filter/get_path.py @@ -180,7 +180,7 @@ def _get_path(*args, **kwargs): class FilterModule(object): - """ path filters """ + """path filters""" def filters(self): return {"get_path": _get_path} diff --git a/plugins/filter/hwaddr.py b/plugins/filter/hwaddr.py index e37f9cc..5a7d9c7 100644 --- a/plugins/filter/hwaddr.py +++ b/plugins/filter/hwaddr.py @@ -98,7 +98,7 @@ RETURN = """ @pass_environment def _hwaddr(*args, **kwargs): - """This filter check if string is a HW/MAC address and filter it """ + """This filter check if string is a HW/MAC address and filter it""" keys = ["value", "query", "alias"] data = dict(zip(keys, args[1:])) data.update(kwargs) @@ -112,8 +112,7 @@ def _hwaddr(*args, **kwargs): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -121,7 +120,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/index_of.py b/plugins/filter/index_of.py index 28a6a0f..874c820 100644 --- a/plugins/filter/index_of.py +++ b/plugins/filter/index_of.py @@ -338,7 +338,7 @@ def _index_of(*args, **kwargs): class FilterModule(object): - """ index_of """ + """index_of""" def filters(self): """a mapping of filter names to functions""" diff --git a/plugins/filter/ip4_hex.py b/plugins/filter/ip4_hex.py index 97a5316..093de7a 100644 --- a/plugins/filter/ip4_hex.py +++ b/plugins/filter/ip4_hex.py @@ -109,7 +109,7 @@ def _ip4_hex(*args, **kwargs): def ip4_hex(arg, delimiter=""): - """ Convert an IPv4 address to Hexadecimal notation """ + """Convert an IPv4 address to Hexadecimal notation""" numbers = list(map(int, arg.split("."))) return "{0:02x}{sep}{1:02x}{sep}{2:02x}{sep}{3:02x}".format( *numbers, sep=delimiter @@ -117,8 +117,7 @@ def ip4_hex(arg, delimiter=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -126,7 +125,7 @@ class FilterModule(object): } def filters(self): - """ ip4_hex filter """ + """ip4_hex filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/ipaddr.py b/plugins/filter/ipaddr.py index 178170f..9c1a490 100644 --- a/plugins/filter/ipaddr.py +++ b/plugins/filter/ipaddr.py @@ -281,8 +281,7 @@ def _ipaddr(*args, **kwargs): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -290,7 +289,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/ipmath.py b/plugins/filter/ipmath.py index a62a833..0ae81cc 100644 --- a/plugins/filter/ipmath.py +++ b/plugins/filter/ipmath.py @@ -169,8 +169,7 @@ def ipmath(value, amount): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # This filter is designed to do simple IP math/arithmetic @@ -178,7 +177,7 @@ class FilterModule(object): } def filters(self): - """ ipmath filter""" + """ipmath filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/ipsubnet.py b/plugins/filter/ipsubnet.py index 69c4170..c0b208c 100644 --- a/plugins/filter/ipsubnet.py +++ b/plugins/filter/ipsubnet.py @@ -253,7 +253,7 @@ def _ipsubnet(*args, **kwargs): def ipsubnet(value, query="", index="x"): - """ Manipulate IPv4/IPv6 subnets """ + """Manipulate IPv4/IPv6 subnets""" try: vtype = ipaddr(value, "type") @@ -323,8 +323,7 @@ def ipsubnet(value, query="", index="x"): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -332,7 +331,7 @@ class FilterModule(object): } def filters(self): - """ ipsubnet filter """ + """ipsubnet filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/ipv4.py b/plugins/filter/ipv4.py index dff3f70..e43023b 100644 --- a/plugins/filter/ipv4.py +++ b/plugins/filter/ipv4.py @@ -160,8 +160,7 @@ def ipv4(value, query=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -169,7 +168,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if netaddr: return self.filter_map else: diff --git a/plugins/filter/ipv6.py b/plugins/filter/ipv6.py index 3bf1156..0a7caa8 100644 --- a/plugins/filter/ipv6.py +++ b/plugins/filter/ipv6.py @@ -178,8 +178,7 @@ def ipv6(value, query=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -187,7 +186,7 @@ class FilterModule(object): } def filters(self): - """ ipv6 filter """ + """ipv6 filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/ipwrap.py b/plugins/filter/ipwrap.py index 53c575b..bcdf8e7 100644 --- a/plugins/filter/ipwrap.py +++ b/plugins/filter/ipwrap.py @@ -200,8 +200,7 @@ def ipwrap(value, query=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -209,7 +208,7 @@ class FilterModule(object): } def filters(self): - """ ipwrap filter """ + """ipwrap filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/macaddr.py b/plugins/filter/macaddr.py index a285415..7075971 100644 --- a/plugins/filter/macaddr.py +++ b/plugins/filter/macaddr.py @@ -95,7 +95,7 @@ RETURN = """ @pass_environment def _macaddr(*args, **kwargs): - """This filter check if string is a HW/MAC address and filter it """ + """This filter check if string is a HW/MAC address and filter it""" keys = ["value", "query"] data = dict(zip(keys, args[1:])) data.update(kwargs) @@ -113,8 +113,7 @@ def macaddr(value, query=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -122,7 +121,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/network_in_network.py b/plugins/filter/network_in_network.py index b071162..6411bc6 100644 --- a/plugins/filter/network_in_network.py +++ b/plugins/filter/network_in_network.py @@ -147,8 +147,7 @@ def network_in_network(value, test): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -156,7 +155,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/network_in_usable.py b/plugins/filter/network_in_usable.py index 8271648..21d79cc 100644 --- a/plugins/filter/network_in_usable.py +++ b/plugins/filter/network_in_usable.py @@ -149,8 +149,7 @@ def network_in_usable(value, test): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -158,7 +157,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/next_nth_usable.py b/plugins/filter/next_nth_usable.py index ce66070..3be81ab 100644 --- a/plugins/filter/next_nth_usable.py +++ b/plugins/filter/next_nth_usable.py @@ -137,8 +137,7 @@ def next_nth_usable(value, offset): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -146,7 +145,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/nthhost.py b/plugins/filter/nthhost.py index 6d13a1e..80aa0c8 100644 --- a/plugins/filter/nthhost.py +++ b/plugins/filter/nthhost.py @@ -110,7 +110,7 @@ def _nthhost(*args, **kwargs): def nthhost(value, query=""): - """ Returns the nth host within a network described by value. """ + """Returns the nth host within a network described by value.""" try: vtype = ipaddr(value, "type") if vtype == "address": @@ -137,8 +137,7 @@ def nthhost(value, query=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -146,7 +145,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/param_list_compare.py b/plugins/filter/param_list_compare.py index 54ae9ab..1f3f343 100644 --- a/plugins/filter/param_list_compare.py +++ b/plugins/filter/param_list_compare.py @@ -212,7 +212,7 @@ def param_list_compare(*args, **kwargs): class FilterModule(object): - """ param_list_compare """ + """param_list_compare""" def filters(self): """a mapping of filter names to functions""" diff --git a/plugins/filter/previous_nth_usable.py b/plugins/filter/previous_nth_usable.py index cc4f802..1e73377 100644 --- a/plugins/filter/previous_nth_usable.py +++ b/plugins/filter/previous_nth_usable.py @@ -136,8 +136,7 @@ def previous_nth_usable(value, offset): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -145,7 +144,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/reduce_on_network.py b/plugins/filter/reduce_on_network.py index 6cbdb9e..860d62f 100644 --- a/plugins/filter/reduce_on_network.py +++ b/plugins/filter/reduce_on_network.py @@ -137,8 +137,7 @@ def reduce_on_network(value, network): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -146,7 +145,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/slaac.py b/plugins/filter/slaac.py index 0a44c17..1a9ca7a 100644 --- a/plugins/filter/slaac.py +++ b/plugins/filter/slaac.py @@ -100,7 +100,7 @@ def _slaac(*args, **kwargs): def slaac(value, query=""): - """ Get the SLAAC address within given network """ + """Get the SLAAC address within given network""" try: vtype = ipaddr(value, "type") if vtype == "address": @@ -129,8 +129,7 @@ def slaac(value, query=""): class FilterModule(object): - """IP address and network manipulation filters - """ + """IP address and network manipulation filters""" filter_map = { # IP addresses and networks @@ -138,7 +137,7 @@ class FilterModule(object): } def filters(self): - """ ipaddr filter """ + """ipaddr filter""" if HAS_NETADDR: return self.filter_map else: diff --git a/plugins/filter/to_paths.py b/plugins/filter/to_paths.py index b343599..567b251 100644 --- a/plugins/filter/to_paths.py +++ b/plugins/filter/to_paths.py @@ -141,7 +141,7 @@ def _to_paths(*args, **kwargs): class FilterModule(object): - """ path filters """ + """path filters""" def filters(self): return {"to_paths": _to_paths} diff --git a/plugins/filter/to_xml.py b/plugins/filter/to_xml.py index 511154f..d4652ba 100644 --- a/plugins/filter/to_xml.py +++ b/plugins/filter/to_xml.py @@ -135,7 +135,7 @@ def _to_xml(*args, **kwargs): class FilterModule(object): - """ to_xml """ + """to_xml""" def filters(self): """a mapping of filter names to functions""" diff --git a/plugins/filter/usable_range.py b/plugins/filter/usable_range.py index 288b8e7..089a5c8 100644 --- a/plugins/filter/usable_range.py +++ b/plugins/filter/usable_range.py @@ -188,7 +188,7 @@ def _usable_range(ip): class FilterModule(object): - """ usable_range """ + """usable_range""" def filters(self): diff --git a/plugins/plugin_utils/base/cli_parser.py b/plugins/plugin_utils/base/cli_parser.py index 5f9ea7c..01cbdd7 100644 --- a/plugins/plugin_utils/base/cli_parser.py +++ b/plugins/plugin_utils/base/cli_parser.py @@ -7,7 +7,7 @@ __metaclass__ = type class CliParserBase: - """ The base class for cli parsers + """The base class for cli parsers Provides a _debug function to normalize parser debug output """ diff --git a/plugins/plugin_utils/base/ipaddr_utils.py b/plugins/plugin_utils/base/ipaddr_utils.py index 6c03720..da083fc 100644 --- a/plugins/plugin_utils/base/ipaddr_utils.py +++ b/plugins/plugin_utils/base/ipaddr_utils.py @@ -368,7 +368,7 @@ def _wrap_query(v, vtype, value): def ipaddr(value, query="", version=False, alias="ipaddr"): - """ Check if string is an IP address or network and filter it """ + """Check if string is an IP address or network and filter it""" query_func_extra_args = { "": ("vtype",), @@ -686,7 +686,7 @@ def _win_query(v): # ---- HWaddr / MAC address filters ---- def hwaddr(value, query="", alias="hwaddr"): - """ Check if string is a HW/MAC address and filter it """ + """Check if string is a HW/MAC address and filter it""" query_func_extra_args = {"": ("value",)} diff --git a/plugins/plugin_utils/base/ipaddress_utils.py b/plugins/plugin_utils/base/ipaddress_utils.py index cbe8624..c6c9875 100644 --- a/plugins/plugin_utils/base/ipaddress_utils.py +++ b/plugins/plugin_utils/base/ipaddress_utils.py @@ -29,8 +29,7 @@ except ImportError: def ip_network(ip): - """ PY2 compat shim, PY2 requires unicode - """ + """PY2 compat shim, PY2 requires unicode""" if not HAS_IPADDRESS: raise AnsibleError(missing_required_lib("ipaddress")) @@ -39,8 +38,7 @@ def ip_network(ip): def ip_address(ip): - """ PY2 compat shim, PY2 requires unicode - """ + """PY2 compat shim, PY2 requires unicode""" if not HAS_IPADDRESS: raise AnsibleError(missing_required_lib("ipaddress")) @@ -71,8 +69,7 @@ def _is_subnet_of(network_a, network_b): def _validate_args(plugin, doc, params): - """ argspec validator utility function - """ + """argspec validator utility function""" valid, argspec_result, updated_params = check_argspec( doc, plugin + " test", **params diff --git a/plugins/plugin_utils/base/utils.py b/plugins/plugin_utils/base/utils.py index 66f35b6..da3da57 100644 --- a/plugins/plugin_utils/base/utils.py +++ b/plugins/plugin_utils/base/utils.py @@ -18,8 +18,7 @@ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_valid def _validate_args(plugin, doc, params): - """ argspec validator utility function - """ + """argspec validator utility function""" valid, argspec_result, updated_params = check_argspec( doc, plugin + " test", **params diff --git a/plugins/sub_plugins/cli_parser/json_parser.py b/plugins/sub_plugins/cli_parser/json_parser.py index 9c095f6..f6bd618 100644 --- a/plugins/sub_plugins/cli_parser/json_parser.py +++ b/plugins/sub_plugins/cli_parser/json_parser.py @@ -44,7 +44,7 @@ from ansible_collections.ansible.utils.plugins.plugin_utils.base.cli_parser impo class CliParser(CliParserBase): - """ The json parser class + """The json parser class Convert a string containing valid json into an object """ @@ -52,7 +52,7 @@ class CliParser(CliParserBase): PROVIDE_TEMPLATE_CONTENTS = False def parse(self, *_args, **_kwargs): - """ Std entry point for a cli_parse parse execution + """Std entry point for a cli_parse parse execution :return: Errors or parsed text as structured data :rtype: dict diff --git a/plugins/sub_plugins/cli_parser/textfsm_parser.py b/plugins/sub_plugins/cli_parser/textfsm_parser.py index 3d1e19b..2e075e5 100644 --- a/plugins/sub_plugins/cli_parser/textfsm_parser.py +++ b/plugins/sub_plugins/cli_parser/textfsm_parser.py @@ -53,7 +53,7 @@ except ImportError: class CliParser(CliParserBase): - """ The textfsm parser class + """The textfsm parser class Convert raw text to structured data using textfsm """ @@ -62,7 +62,7 @@ class CliParser(CliParserBase): @staticmethod def _check_reqs(): - """ Check the prerequisites for the textfsm parser + """Check the prerequisites for the textfsm parser :return dict: A dict with errors or a template_path """ @@ -74,7 +74,7 @@ class CliParser(CliParserBase): return {"errors": errors} def parse(self, *_args, **_kwargs): - """ Std entry point for a cli_parse parse execution + """Std entry point for a cli_parse parse execution :return: Errors or parsed text as structured data :rtype: dict diff --git a/plugins/sub_plugins/cli_parser/ttp_parser.py b/plugins/sub_plugins/cli_parser/ttp_parser.py index bd8098d..f3d7960 100644 --- a/plugins/sub_plugins/cli_parser/ttp_parser.py +++ b/plugins/sub_plugins/cli_parser/ttp_parser.py @@ -53,7 +53,7 @@ except ImportError: class CliParser(CliParserBase): - """ The ttp parser class + """The ttp parser class Convert raw text to structured data using ttp """ @@ -62,7 +62,7 @@ class CliParser(CliParserBase): @staticmethod def _check_reqs(): - """ Check the prerequisites for the ttp parser + """Check the prerequisites for the ttp parser :return dict: A dict with errors or a template_path """ @@ -74,7 +74,7 @@ class CliParser(CliParserBase): return {"errors": errors} def parse(self, *_args, **_kwargs): - """ Std entry point for a cli_parse parse execution + """Std entry point for a cli_parse parse execution :return: Errors or parsed text as structured data :rtype: dict diff --git a/plugins/sub_plugins/cli_parser/xml_parser.py b/plugins/sub_plugins/cli_parser/xml_parser.py index ea2e52b..b81ed93 100644 --- a/plugins/sub_plugins/cli_parser/xml_parser.py +++ b/plugins/sub_plugins/cli_parser/xml_parser.py @@ -52,7 +52,7 @@ except ImportError: class CliParser(CliParserBase): - """ The xml parser class + """The xml parser class Convert an xml string to structured data using xmltodict """ @@ -61,8 +61,7 @@ class CliParser(CliParserBase): @staticmethod def _check_reqs(): - """ Check the prerequisites for the xml parser - """ + """Check the prerequisites for the xml parser""" errors = [] if not HAS_XMLTODICT: errors.append(missing_required_lib("xmltodict")) @@ -70,7 +69,7 @@ class CliParser(CliParserBase): return errors def parse(self, *_args, **_kwargs): - """ Std entry point for a cli_parse parse execution + """Std entry point for a cli_parse parse execution :return: Errors or parsed text as structured data :rtype: dict diff --git a/plugins/sub_plugins/validate/jsonschema.py b/plugins/sub_plugins/validate/jsonschema.py index 53e2355..d9d3a90 100644 --- a/plugins/sub_plugins/validate/jsonschema.py +++ b/plugins/sub_plugins/validate/jsonschema.py @@ -205,9 +205,11 @@ class Validate(ValidateBase): "found": validation_error.instance, } self._result["errors"].append(error) - error_message = "At '{schema_path}' {message}. ".format( - schema_path=error["schema_path"], - message=error["message"], + error_message = ( + "At '{schema_path}' {message}. ".format( + schema_path=error["schema_path"], + message=error["message"], + ) ) error_messages.append(error_message) if error_messages: diff --git a/plugins/test/in_any_network.py b/plugins/test/in_any_network.py index 213dc89..e213afe 100644 --- a/plugins/test/in_any_network.py +++ b/plugins/test/in_any_network.py @@ -104,7 +104,7 @@ def _in_any_network(ip, networks): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"in_any_network": _in_any_network} diff --git a/plugins/test/in_network.py b/plugins/test/in_network.py index 9b667b2..fd1ac19 100644 --- a/plugins/test/in_network.py +++ b/plugins/test/in_network.py @@ -120,7 +120,7 @@ def _in_network(ip, network): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"in_network": _in_network} diff --git a/plugins/test/in_one_network.py b/plugins/test/in_one_network.py index 7850252..b3c1b68 100644 --- a/plugins/test/in_one_network.py +++ b/plugins/test/in_one_network.py @@ -103,7 +103,7 @@ def _in_one_network(ip, networks): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"in_one_network": _in_one_network} diff --git a/plugins/test/ip.py b/plugins/test/ip.py index 08dcb9c..a2a5202 100644 --- a/plugins/test/ip.py +++ b/plugins/test/ip.py @@ -114,7 +114,7 @@ RETURN = """ @_need_ipaddress def _ip(ip): - """ Test if something in an IP address or network """ + """Test if something in an IP address or network""" params = {"ip": ip} _validate_args("ip", DOCUMENTATION, params) @@ -127,7 +127,7 @@ def _ip(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ip": _ip} diff --git a/plugins/test/ip_address.py b/plugins/test/ip_address.py index 6682a16..36e3969 100644 --- a/plugins/test/ip_address.py +++ b/plugins/test/ip_address.py @@ -103,7 +103,7 @@ def _ip_address(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ip_address": _ip_address} diff --git a/plugins/test/ipv4.py b/plugins/test/ipv4.py index e66c3c6..fa55853 100644 --- a/plugins/test/ipv4.py +++ b/plugins/test/ipv4.py @@ -100,7 +100,7 @@ def _ipv4(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv4": _ipv4} diff --git a/plugins/test/ipv4_address.py b/plugins/test/ipv4_address.py index bb7d0bb..7ab1bc5 100644 --- a/plugins/test/ipv4_address.py +++ b/plugins/test/ipv4_address.py @@ -102,7 +102,7 @@ def _ipv4_address(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv4_address": _ipv4_address} diff --git a/plugins/test/ipv4_hostmask.py b/plugins/test/ipv4_hostmask.py index e201203..8a86885 100644 --- a/plugins/test/ipv4_hostmask.py +++ b/plugins/test/ipv4_hostmask.py @@ -90,7 +90,7 @@ def _ipv4_hostmask(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv4_hostmask": _ipv4_hostmask} diff --git a/plugins/test/ipv4_netmask.py b/plugins/test/ipv4_netmask.py index e12d0b8..d3934a3 100644 --- a/plugins/test/ipv4_netmask.py +++ b/plugins/test/ipv4_netmask.py @@ -89,7 +89,7 @@ RETURN = """ @_need_ipaddress def _ipv4_netmask(mask): - """ Test for a valid IPv4 netmask""" + """Test for a valid IPv4 netmask""" params = {"mask": mask} _validate_args("ipv4_netmask", DOCUMENTATION, params) @@ -102,7 +102,7 @@ def _ipv4_netmask(mask): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv4_netmask": _ipv4_netmask} diff --git a/plugins/test/ipv6.py b/plugins/test/ipv6.py index a3299df..ea2204d 100644 --- a/plugins/test/ipv6.py +++ b/plugins/test/ipv6.py @@ -102,7 +102,7 @@ def _ipv6(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv6": _ipv6} diff --git a/plugins/test/ipv6_address.py b/plugins/test/ipv6_address.py index ae8a3a7..fa1aa88 100644 --- a/plugins/test/ipv6_address.py +++ b/plugins/test/ipv6_address.py @@ -102,7 +102,7 @@ def _ipv6_address(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv6_address": _ipv6_address} diff --git a/plugins/test/ipv6_ipv4_mapped.py b/plugins/test/ipv6_ipv4_mapped.py index 18c4f10..30e3af5 100644 --- a/plugins/test/ipv6_ipv4_mapped.py +++ b/plugins/test/ipv6_ipv4_mapped.py @@ -88,7 +88,7 @@ RETURN = """ @_need_ipaddress def _ipv6_ipv4_mapped(ip): - """ Test if something appears to be a mapped IPv6 to IPv4 mapped address """ + """Test if something appears to be a mapped IPv6 to IPv4 mapped address""" params = {"ip": ip} _validate_args("ipv6_ipv4_mapped", DOCUMENTATION, params) @@ -102,7 +102,7 @@ def _ipv6_ipv4_mapped(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv6_ipv4_mapped": _ipv6_ipv4_mapped} diff --git a/plugins/test/ipv6_sixtofour.py b/plugins/test/ipv6_sixtofour.py index f0eda79..ef5b752 100644 --- a/plugins/test/ipv6_sixtofour.py +++ b/plugins/test/ipv6_sixtofour.py @@ -90,7 +90,7 @@ RETURN = """ @_need_ipaddress def _ipv6_sixtofour(ip): - """ Test if something appears to be a 6to4 address """ + """Test if something appears to be a 6to4 address""" params = {"ip": ip} _validate_args("ipv6_sixtofour", DOCUMENTATION, params) @@ -104,7 +104,7 @@ def _ipv6_sixtofour(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv6_sixtofour": _ipv6_sixtofour} diff --git a/plugins/test/ipv6_teredo.py b/plugins/test/ipv6_teredo.py index 32bc5d5..1d8bcc9 100644 --- a/plugins/test/ipv6_teredo.py +++ b/plugins/test/ipv6_teredo.py @@ -90,7 +90,7 @@ RETURN = """ @_need_ipaddress def _ipv6_teredo(ip): - """ Test if something is an IPv6 teredo address """ + """Test if something is an IPv6 teredo address""" params = {"ip": ip} _validate_args("ipv6_teredo", DOCUMENTATION, params) @@ -104,7 +104,7 @@ def _ipv6_teredo(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"ipv6_teredo": _ipv6_teredo} diff --git a/plugins/test/loopback.py b/plugins/test/loopback.py index ccd193c..2615998 100644 --- a/plugins/test/loopback.py +++ b/plugins/test/loopback.py @@ -85,7 +85,7 @@ RETURN = """ @_need_ipaddress def _loopback(ip): - """ Test if an IP address is a loopback """ + """Test if an IP address is a loopback""" params = {"ip": ip} _validate_args("loopback", DOCUMENTATION, params) @@ -97,7 +97,7 @@ def _loopback(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"loopback": _loopback} diff --git a/plugins/test/mac.py b/plugins/test/mac.py index f39e935..cb258e6 100644 --- a/plugins/test/mac.py +++ b/plugins/test/mac.py @@ -109,7 +109,7 @@ RETURN = """ def _mac(mac): - """ Test if something appears to be a valid mac address """ + """Test if something appears to be a valid mac address""" params = {"mac": mac} _validate_args("mac", DOCUMENTATION, params) @@ -125,7 +125,7 @@ def _mac(mac): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"mac": _mac} diff --git a/plugins/test/multicast.py b/plugins/test/multicast.py index e7ce40b..bd204a1 100644 --- a/plugins/test/multicast.py +++ b/plugins/test/multicast.py @@ -100,7 +100,7 @@ RETURN = """ @_need_ipaddress def _multicast(ip): - """ Test for a multicast IP address """ + """Test for a multicast IP address""" params = {"ip": ip} _validate_args("multicast", DOCUMENTATION, params) @@ -112,7 +112,7 @@ def _multicast(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"multicast": _multicast} diff --git a/plugins/test/private.py b/plugins/test/private.py index 4c080ce..915bb23 100644 --- a/plugins/test/private.py +++ b/plugins/test/private.py @@ -76,7 +76,7 @@ RETURN = """ @_need_ipaddress def _private(ip): - """ Test if an IP address is private """ + """Test if an IP address is private""" params = {"ip": ip} _validate_args("private", DOCUMENTATION, params) @@ -88,7 +88,7 @@ def _private(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"private": _private} diff --git a/plugins/test/public.py b/plugins/test/public.py index a0973db..abd4048 100644 --- a/plugins/test/public.py +++ b/plugins/test/public.py @@ -74,7 +74,7 @@ RETURN = """ @_need_ipaddress def _public(ip): - """ Test if an IP address is public """ + """Test if an IP address is public""" params = {"ip": ip} _validate_args("public", DOCUMENTATION, params) @@ -86,7 +86,7 @@ def _public(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"public": _public} diff --git a/plugins/test/reserved.py b/plugins/test/reserved.py index 62679b7..52ddcf1 100644 --- a/plugins/test/reserved.py +++ b/plugins/test/reserved.py @@ -75,7 +75,7 @@ RETURN = """ @_need_ipaddress def _reserved(ip): - """ Test for a reserved IP address """ + """Test for a reserved IP address""" params = {"ip": ip} _validate_args("reserved", DOCUMENTATION, params) @@ -87,7 +87,7 @@ def _reserved(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"reserved": _reserved} diff --git a/plugins/test/resolvable.py b/plugins/test/resolvable.py index 9588106..a7b5eaf 100644 --- a/plugins/test/resolvable.py +++ b/plugins/test/resolvable.py @@ -123,7 +123,7 @@ RETURN = """ @_need_ipaddress def _resolvable(host): - """ Test if an IP or name can be resolved via /etc/hosts or DNS """ + """Test if an IP or name can be resolved via /etc/hosts or DNS""" params = {"host": host} _validate_args("resolvable", DOCUMENTATION, params) @@ -148,7 +148,7 @@ def _resolvable(host): class TestModule(object): - """ network jinja tests """ + """network jinja tests""" test_map = {"resolvable": _resolvable} diff --git a/plugins/test/subnet_of.py b/plugins/test/subnet_of.py index 3b08746..0deeb13 100644 --- a/plugins/test/subnet_of.py +++ b/plugins/test/subnet_of.py @@ -80,7 +80,7 @@ RETURN = """ @_need_ipaddress def _subnet_of(network_a, network_b): - """ Test if a network is a subnet of another network """ + """Test if a network is a subnet of another network""" params = {"network_a": network_a, "network_b": network_b} _validate_args("subnet_of", DOCUMENTATION, params) @@ -92,7 +92,7 @@ def _subnet_of(network_a, network_b): class TestModule(object): - """ network jinja test """ + """network jinja test""" test_map = {"subnet_of": _subnet_of} diff --git a/plugins/test/supernet_of.py b/plugins/test/supernet_of.py index 9065a61..3318904 100644 --- a/plugins/test/supernet_of.py +++ b/plugins/test/supernet_of.py @@ -82,7 +82,7 @@ RETURN = """ @_need_ipaddress def _supernet_of(network_a, network_b): - """ Test if an network is a supernet of another network """ + """Test if an network is a supernet of another network""" params = {"network_a": network_a, "network_b": network_b} _validate_args("supernet_of", DOCUMENTATION, params) @@ -94,7 +94,7 @@ def _supernet_of(network_a, network_b): class TestModule(object): - """ network jinja test """ + """network jinja test""" test_map = {"supernet_of": _supernet_of} diff --git a/plugins/test/unspecified.py b/plugins/test/unspecified.py index 6e79e9e..f771679 100644 --- a/plugins/test/unspecified.py +++ b/plugins/test/unspecified.py @@ -101,7 +101,7 @@ RETURN = """ @_need_ipaddress def _unspecified(ip): - """ Test for an unspecified IP address """ + """Test for an unspecified IP address""" params = {"ip": ip} _validate_args("unspecified", DOCUMENTATION, params) @@ -113,7 +113,7 @@ def _unspecified(ip): class TestModule(object): - """ network jinja test""" + """network jinja test""" test_map = {"unspecified": _unspecified} diff --git a/tests/integration/targets/utils_cli_parse/files/nxos_show_version.txt b/tests/integration/targets/utils_cli_parse/files/nxos_show_version.txt index d5a63e8..47ade78 100644 --- a/tests/integration/targets/utils_cli_parse/files/nxos_show_version.txt +++ b/tests/integration/targets/utils_cli_parse/files/nxos_show_version.txt @@ -34,4 +34,4 @@ Kernel uptime is 110 day(s), 12 hour(s), 32 minute(s), 10 second(s) plugin Core Plugin, Ethernet Plugin -Active Package(s) \ No newline at end of file +Active Package(s) diff --git a/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_json_text.txt b/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_json_text.txt index 5fc41f7..3d3c383 100644 --- a/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_json_text.txt +++ b/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_json_text.txt @@ -15,4 +15,4 @@ } ] ] -] \ No newline at end of file +] diff --git a/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_ttp_parsed.json b/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_ttp_parsed.json index 5fc41f7..3d3c383 100644 --- a/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_ttp_parsed.json +++ b/tests/integration/targets/utils_cli_parse/output/nxos_show_interface_ttp_parsed.json @@ -15,4 +15,4 @@ } ] ] -] \ No newline at end of file +] diff --git a/tests/integration/targets/utils_cli_parse/templates/centos_df_-h.ttp b/tests/integration/targets/utils_cli_parse/templates/centos_df_-h.ttp index ddd709d..75b4875 100644 --- a/tests/integration/targets/utils_cli_parse/templates/centos_df_-h.ttp +++ b/tests/integration/targets/utils_cli_parse/templates/centos_df_-h.ttp @@ -1 +1 @@ -Filesystem Size Used Avail Use Mounted_on {{ _headers_ }} \ No newline at end of file +Filesystem Size Used Avail Use Mounted_on {{ _headers_ }} diff --git a/tests/integration/targets/utils_cli_parse/templates/centos_ifconfig.textfsm b/tests/integration/targets/utils_cli_parse/templates/centos_ifconfig.textfsm index 4c339c2..b16da4e 100644 --- a/tests/integration/targets/utils_cli_parse/templates/centos_ifconfig.textfsm +++ b/tests/integration/targets/utils_cli_parse/templates/centos_ifconfig.textfsm @@ -16,4 +16,4 @@ Start ^${Interface}:.* mtu ${MTU} ^\s+ether ${MAC} ^\s+inet6 ${Inet6} prefixlen ${Prefix} - ^\s+inet ${Inet} netmask ${Netmask} \ No newline at end of file + ^\s+inet ${Inet} netmask ${Netmask} diff --git a/tests/integration/targets/utils_cli_parse/templates/fedora_df_-h.ttp b/tests/integration/targets/utils_cli_parse/templates/fedora_df_-h.ttp index ddd709d..75b4875 100644 --- a/tests/integration/targets/utils_cli_parse/templates/fedora_df_-h.ttp +++ b/tests/integration/targets/utils_cli_parse/templates/fedora_df_-h.ttp @@ -1 +1 @@ -Filesystem Size Used Avail Use Mounted_on {{ _headers_ }} \ No newline at end of file +Filesystem Size Used Avail Use Mounted_on {{ _headers_ }} diff --git a/tests/integration/targets/utils_cli_parse/templates/fedora_ifconfig.textfsm b/tests/integration/targets/utils_cli_parse/templates/fedora_ifconfig.textfsm index 4c339c2..b16da4e 100644 --- a/tests/integration/targets/utils_cli_parse/templates/fedora_ifconfig.textfsm +++ b/tests/integration/targets/utils_cli_parse/templates/fedora_ifconfig.textfsm @@ -16,4 +16,4 @@ Start ^${Interface}:.* mtu ${MTU} ^\s+ether ${MAC} ^\s+inet6 ${Inet6} prefixlen ${Prefix} - ^\s+inet ${Inet} netmask ${Netmask} \ No newline at end of file + ^\s+inet ${Inet} netmask ${Netmask} diff --git a/tests/integration/targets/utils_cli_parse/templates/ubuntu_df_-h.ttp b/tests/integration/targets/utils_cli_parse/templates/ubuntu_df_-h.ttp index ddd709d..75b4875 100644 --- a/tests/integration/targets/utils_cli_parse/templates/ubuntu_df_-h.ttp +++ b/tests/integration/targets/utils_cli_parse/templates/ubuntu_df_-h.ttp @@ -1 +1 @@ -Filesystem Size Used Avail Use Mounted_on {{ _headers_ }} \ No newline at end of file +Filesystem Size Used Avail Use Mounted_on {{ _headers_ }} diff --git a/tests/integration/targets/utils_cli_parse/templates/ubuntu_ifconfig.textfsm b/tests/integration/targets/utils_cli_parse/templates/ubuntu_ifconfig.textfsm index 4c339c2..b16da4e 100644 --- a/tests/integration/targets/utils_cli_parse/templates/ubuntu_ifconfig.textfsm +++ b/tests/integration/targets/utils_cli_parse/templates/ubuntu_ifconfig.textfsm @@ -16,4 +16,4 @@ Start ^${Interface}:.* mtu ${MTU} ^\s+ether ${MAC} ^\s+inet6 ${Inet6} prefixlen ${Prefix} - ^\s+inet ${Inet} netmask ${Netmask} \ No newline at end of file + ^\s+inet ${Inet} netmask ${Netmask} diff --git a/tests/integration/targets/utils_ipaddr_filter/vars/main.yaml b/tests/integration/targets/utils_ipaddr_filter/vars/main.yaml index 15bc0d2..6a87ef7 100644 --- a/tests/integration/targets/utils_ipaddr_filter/vars/main.yaml +++ b/tests/integration/targets/utils_ipaddr_filter/vars/main.yaml @@ -40,7 +40,7 @@ ipwrap_result1: - "[fe80::100]/10" - "[2001:db8:32c:faad::]/64" - True - + ipv6_result1: - "::ffff:192.168.32.0/120" - "::ffff:192.24.2.1/128" diff --git a/tests/integration/targets/utils_validate/files/criteria/check_list_data.json b/tests/integration/targets/utils_validate/files/criteria/check_list_data.json index d45e16c..77efa81 100644 --- a/tests/integration/targets/utils_validate/files/criteria/check_list_data.json +++ b/tests/integration/targets/utils_validate/files/criteria/check_list_data.json @@ -14,4 +14,4 @@ ], "default": 0 } -} \ No newline at end of file +} diff --git a/tests/integration/targets/utils_validate/files/criteria/crc_error_check.json b/tests/integration/targets/utils_validate/files/criteria/crc_error_check.json index 66c43ca..9e9d3e7 100644 --- a/tests/integration/targets/utils_validate/files/criteria/crc_error_check.json +++ b/tests/integration/targets/utils_validate/files/criteria/crc_error_check.json @@ -15,4 +15,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/integration/targets/utils_validate/files/criteria/enabled_check.json b/tests/integration/targets/utils_validate/files/criteria/enabled_check.json index dde7c05..5dbe4f3 100644 --- a/tests/integration/targets/utils_validate/files/criteria/enabled_check.json +++ b/tests/integration/targets/utils_validate/files/criteria/enabled_check.json @@ -10,4 +10,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/integration/targets/utils_validate/files/criteria/in_rate_check.json b/tests/integration/targets/utils_validate/files/criteria/in_rate_check.json index 94614ea..6bc0b9c 100644 --- a/tests/integration/targets/utils_validate/files/criteria/in_rate_check.json +++ b/tests/integration/targets/utils_validate/files/criteria/in_rate_check.json @@ -19,4 +19,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/integration/targets/utils_validate/files/criteria/oper_status_up.json b/tests/integration/targets/utils_validate/files/criteria/oper_status_up.json index 2f5803a..2c5ce0f 100644 --- a/tests/integration/targets/utils_validate/files/criteria/oper_status_up.json +++ b/tests/integration/targets/utils_validate/files/criteria/oper_status_up.json @@ -11,4 +11,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/unit/module_utils/fixtures/large.json b/tests/unit/module_utils/fixtures/large.json index 51b7509..fa6b6b9 100644 --- a/tests/unit/module_utils/fixtures/large.json +++ b/tests/unit/module_utils/fixtures/large.json @@ -55315,4 +55315,4 @@ }, "xmlns": "http://cisco.com/ns/yang/cisco-nx-os-device" } -} \ No newline at end of file +} diff --git a/tests/unit/plugins/action/fixtures/nxos_show_version.txt b/tests/unit/plugins/action/fixtures/nxos_show_version.txt index a50e668..b797d71 100644 --- a/tests/unit/plugins/action/fixtures/nxos_show_version.txt +++ b/tests/unit/plugins/action/fixtures/nxos_show_version.txt @@ -35,4 +35,4 @@ Last reset plugin Core Plugin, Ethernet Plugin -Active Package(s): \ No newline at end of file +Active Package(s): diff --git a/tests/unit/plugins/action/test_cli_parse.py b/tests/unit/plugins/action/test_cli_parse.py index 901033e..7573bb7 100644 --- a/tests/unit/plugins/action/test_cli_parse.py +++ b/tests/unit/plugins/action/test_cli_parse.py @@ -58,7 +58,7 @@ class TestCli_Parse(unittest.TestCase): @staticmethod def _load_fixture(filename): - """ Load a fixture from the filesystem + """Load a fixture from the filesystem :param filename: The name of the file to load :type filename: str @@ -72,23 +72,20 @@ class TestCli_Parse(unittest.TestCase): return fhand.read() def test_fn_debug(self): - """ Confirm debug doesn't fail and return None - """ + """Confirm debug doesn't fail and return None""" msg = "some message" result = self._plugin._debug(msg) self.assertEqual(result, None) def test_fn_ail_json(self): - """ Confirm fail json replaces basic.py in msg - """ + """Confirm fail json replaces basic.py in msg""" msg = "text (basic.py)" with self.assertRaises(Exception) as error: self._plugin._fail_json(msg) self.assertEqual("text cli_parse", str(error.exception)) def test_fn_check_argspec_pass(self): - """ Confirm a valid argspec passes - """ + """Confirm a valid argspec passes""" kwargs = { "text": "text", "parser": { @@ -102,8 +99,7 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(valid, True) def test_fn_check_argspec_fail_no_test_or_command(self): - """ Confirm failed argpsec w/o text or command - """ + """Confirm failed argpsec w/o text or command""" kwargs = { "parser": { "name": "ansible.utils.textfsm", @@ -122,8 +118,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_check_argspec_fail_no_parser_name(self): - """ Confirm failed argspec no parser name - """ + """Confirm failed argspec no parser name""" kwargs = {"text": "anything", "parser": {"command": "show version"}} valid, result, updated_params = check_argspec( DOCUMENTATION, @@ -137,8 +132,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_extended_check_argspec_parser_name_not_coll(self): - """ Confirm failed argpsec parser not collection format - """ + """Confirm failed argpsec parser not collection format""" self._plugin._task.args = { "text": "anything", "parser": { @@ -151,7 +145,7 @@ class TestCli_Parse(unittest.TestCase): self.assertIn("including collection", self._plugin._result["msg"]) def test_fn_extended_check_argspec_missing_tpath_or_command(self): - """ Confirm failed argpsec missing template_path + """Confirm failed argpsec missing template_path or command when text provided """ self._plugin._task.args = { @@ -165,8 +159,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_load_parser_pass(self): - """ Confirm each each of the parsers loads from the filesystem - """ + """Confirm each each of the parsers loads from the filesystem""" parser_names = ["json", "textfsm", "ttp", "xml"] for parser_name in parser_names: self._plugin._task.args = { @@ -179,8 +172,7 @@ class TestCli_Parse(unittest.TestCase): self.assertTrue(callable(parser.parse)) def test_fn_load_parser_fail(self): - """ Confirm missing parser fails gracefully - """ + """Confirm missing parser fails gracefully""" self._plugin._task.args = { "text": "anything", "parser": {"name": "a.b.c"}, @@ -191,7 +183,7 @@ class TestCli_Parse(unittest.TestCase): self.assertIn("No module named", self._plugin._result["msg"]) def test_fn_set_parser_command_missing(self): - """ Confirm parser/command is set if missing + """Confirm parser/command is set if missing and command provided """ self._plugin._task.args = { @@ -204,8 +196,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_set_parser_command_present(self): - """ Confirm parser/command is not changed if provided - """ + """Confirm parser/command is not changed if provided""" self._plugin._task.args = { "command": "anything", "parser": {"command": "something", "name": "a.b.c"}, @@ -216,15 +207,13 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_set_parser_command_absent(self): - """ Confirm parser/command is not added - """ + """Confirm parser/command is not added""" self._plugin._task.args = {"parser": {}} self._plugin._set_parser_command() self.assertNotIn("command", self._plugin._task.args["parser"]) def test_fn_set_text_present(self): - """ Check task args text is set to stdout - """ + """Check task args text is set to stdout""" expected = "output" self._plugin._result["stdout"] = expected self._plugin._task.args = {} @@ -232,16 +221,14 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(self._plugin._task.args["text"], expected) def test_fn_set_text_absent(self): - """ Check task args text is set to stdout - """ + """Check task args text is set to stdout""" self._plugin._result["stdout"] = None self._plugin._task.args = {} self._plugin._set_text() self.assertNotIn("text", self._plugin._task.args) def test_fn_os_from_task_vars(self): - """ Confirm os is set based on task vars - """ + """Confirm os is set based on task vars""" checks = [ ("ansible_network_os", "cisco.nxos.nxos", "nxos"), ("ansible_network_os", "NXOS", "nxos"), @@ -254,7 +241,7 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(result, check[2]) def test_fn_update_template_path_not_exist(self): - """ Check the creation of the template_path if + """Check the creation of the template_path if it doesn't exist in the user provided data """ self._plugin._task.args = { @@ -269,7 +256,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_update_template_path_not_exist_os(self): - """ Check the creation of the template_path if + """Check the creation of the template_path if it doesn't exist in the user provided data name based on os provided in task """ @@ -284,7 +271,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_update_template_path_mock_find_needle(self): - """ Check the creation of the template_path + """Check the creation of the template_path mock the find needle fn so the template doesn't need to be in the default template folder """ @@ -302,8 +289,7 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_get_template_contents_pass(self): - """ Check the retrieval of the template contents - """ + """Check the retrieval of the template contents""" temp = tempfile.NamedTemporaryFile() contents = "abcdef" with open(temp.name, "w") as fileh: @@ -314,8 +300,7 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(result, contents) def test_fn_get_template_contents_missing(self): - """ Check the retrieval of the template contents - """ + """Check the retrieval of the template contents""" self._plugin._task.args = {"parser": {"template_path": "non-exist"}} with self.assertRaises(Exception) as error: self._plugin._get_template_contents() @@ -324,15 +309,13 @@ class TestCli_Parse(unittest.TestCase): ) def test_fn_get_template_contents_not_specified(self): - """ Check the none when template_path not specified - """ + """Check the none when template_path not specified""" self._plugin._task.args = {"parser": {}} result = self._plugin._get_template_contents() self.assertIsNone(result) def test_fn_prune_result_pass(self): - """ Test the removal of stdout and stdout_lines from the _result - """ + """Test the removal of stdout and stdout_lines from the _result""" self._plugin._result["stdout"] = "abc" self._plugin._result["stdout_lines"] = "abc" self._plugin._prune_result() @@ -340,15 +323,13 @@ class TestCli_Parse(unittest.TestCase): self.assertNotIn("stdout_lines", self._plugin._result) def test_fn_prune_result_not_exist(self): - """ Test the removal of stdout and stdout_lines from the _result - """ + """Test the removal of stdout and stdout_lines from the _result""" self._plugin._prune_result() self.assertNotIn("stdout", self._plugin._result) self.assertNotIn("stdout_lines", self._plugin._result) def test_fn_run_command_lx_rc0(self): - """ Check run command for non network - """ + """Check run command for non network""" response = "abc" self._plugin._connection.socket_path = None self._plugin._low_level_execute_command = MagicMock() @@ -363,8 +344,7 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(self._plugin._result["stdout_lines"], response) def test_fn_run_command_lx_rc1(self): - """ Check run command for non network - """ + """Check run command for non network""" response = "abc" self._plugin._connection.socket_path = None self._plugin._low_level_execute_command = MagicMock() @@ -381,8 +361,7 @@ class TestCli_Parse(unittest.TestCase): @patch("ansible.module_utils.connection.Connection.__rpc__") def test_fn_run_command_network(self, mock_rpc): - """ Check run command for network - """ + """Check run command for network""" expected = "abc" mock_rpc.return_value = expected self._plugin._connection.socket_path = ( @@ -394,16 +373,14 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(self._plugin._result["stdout_lines"], [expected]) def test_fn_run_command_not_specified(self): - """ Check run command for network - """ + """Check run command for network""" self._plugin._task.args = {"command": None} result = self._plugin._run_command() self.assertIsNone(result) @patch("ansible.module_utils.connection.Connection.__rpc__") def test_fn_run_pass_w_fact(self, mock_rpc): - """ Check full module run with valid params - """ + """Check full module run with valid params""" mock_out = self._load_fixture("nxos_show_version.txt") mock_rpc.return_value = mock_out self._plugin._connection.socket_path = ( @@ -431,8 +408,7 @@ class TestCli_Parse(unittest.TestCase): @patch("ansible.module_utils.connection.Connection.__rpc__") def test_fn_run_pass_wo_fact(self, mock_rpc): - """ Check full module run with valid params - """ + """Check full module run with valid params""" mock_out = self._load_fixture("nxos_show_version.txt") mock_rpc.return_value = mock_out self._plugin._connection.socket_path = ( @@ -456,8 +432,7 @@ class TestCli_Parse(unittest.TestCase): self.assertNotIn("ansible_facts", result) def test_fn_run_fail_argspec(self): - """ Check full module run with invalid params - """ + """Check full module run with invalid params""" self._plugin._task.args = { "text": "anything", "parser": { @@ -470,8 +445,7 @@ class TestCli_Parse(unittest.TestCase): self.assertIn("including collection", self._plugin._result["msg"]) def test_fn_run_fail_command(self): - """ Confirm clean fail with rc 1 - """ + """Confirm clean fail with rc 1""" self._plugin._connection.socket_path = None self._plugin._low_level_execute_command = MagicMock() self._plugin._low_level_execute_command.return_value = { @@ -495,8 +469,7 @@ class TestCli_Parse(unittest.TestCase): self.assertEqual(result, expected) def test_fn_run_fail_missing_parser(self): - """Confirm clean fail with missing parser - """ + """Confirm clean fail with missing parser""" self._plugin._task.args = {"text": None, "parser": {"name": "a.b.c"}} task_vars = {"inventory_hostname": "mockdevice"} result = self._plugin.run(task_vars=task_vars) @@ -505,7 +478,7 @@ class TestCli_Parse(unittest.TestCase): @patch("ansible.module_utils.connection.Connection.__rpc__") def test_fn_run_pass_missing_parser_constants(self, mock_rpc): - """ Check full module run using parser w/o + """Check full module run using parser w/o DEFAULT_TEMPLATE_EXTENSION or PROVIDE_TEMPLATE_CONTENTS defined in the parser """ @@ -542,7 +515,7 @@ class TestCli_Parse(unittest.TestCase): @patch("ansible.module_utils.connection.Connection.__rpc__") def test_fn_run_pass_missing_parser_in_parser(self, mock_rpc): - """ Check full module run using parser w/o + """Check full module run using parser w/o a parser function defined in the parser defined in the parser """ @@ -577,8 +550,7 @@ class TestCli_Parse(unittest.TestCase): @patch("ansible.module_utils.connection.Connection.__rpc__") def test_fn_run_net_device_error(self, mock_rpc): - """ Check full module run mock error from network device - """ + """Check full module run mock error from network device""" msg = "I was mocked" mock_rpc.side_effect = AnsibleConnectionError(msg) self._plugin._connection.socket_path = ( diff --git a/tests/unit/plugins/filter/test_ipmath.py b/tests/unit/plugins/filter/test_ipmath.py index a6248f6..80f6183 100644 --- a/tests/unit/plugins/filter/test_ipmath.py +++ b/tests/unit/plugins/filter/test_ipmath.py @@ -28,7 +28,7 @@ class TestIpAddr(unittest.TestCase): self.assertEqual(result, "192.168.1.10") def test_find_previous_fifth_address(self): - """Get the previous fifth address """ + """Get the previous fifth address""" args = ["", "192.168.1.5", -10] result = _ipmath(*args) diff --git a/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.cfg b/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.cfg index e5cad05..c4c36b8 100644 --- a/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.cfg +++ b/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.cfg @@ -12,15 +12,15 @@ http://www.gnu.org/licenses/gpl.html. Nexus 9000v is a demo version of the Nexus Operating System Software - BIOS: version + BIOS: version NXOS: version 7.0(3)I7(1) - BIOS compile time: + BIOS compile time: NXOS image file is: bootflash:///nxos.7.0.3.I7.1.bin NXOS compile time: 8/31/2017 14:00:00 [08/31/2017 22:29:32] Hardware - cisco Nexus9000 9000v Chassis + cisco Nexus9000 9000v Chassis with 4041236 kB of memory. Processor Board ID 96NK4OUJH32 @@ -28,10 +28,10 @@ Hardware bootflash: 3509454 kB Kernel uptime is 12 day(s), 23 hour(s), 48 minute(s), 10 second(s) -Last reset +Last reset Reason: Unknown - System version: - Service: + System version: + Service: plugin Core Plugin, Ethernet Plugin diff --git a/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.ttp b/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.ttp index c46fc62..8880886 100644 --- a/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.ttp +++ b/tests/unit/plugins/sub_plugins/cli_parsers/fixtures/nxos_show_version.ttp @@ -4,4 +4,4 @@ Kernel uptime is {{ uptime | ORPHRASE }} cisco Nexus9000 {{ platform }} Chassis -""" \ No newline at end of file +""" diff --git a/tests/unit/plugins/sub_plugins/validate/test_config.py b/tests/unit/plugins/sub_plugins/validate/test_config.py index b524457..c4ca62e 100644 --- a/tests/unit/plugins/sub_plugins/validate/test_config.py +++ b/tests/unit/plugins/sub_plugins/validate/test_config.py @@ -71,8 +71,10 @@ def test_invalid_action(validator, test_rule): except AnsibleError as exc: error = to_text(exc) - expected_error = 'Action in criteria {item} is not one of "warn" or "fail"'.format( - item=original + expected_error = ( + 'Action in criteria {item} is not one of "warn" or "fail"'.format( + item=original + ) ) assert error == expected_error From 29c8072e092b15b6e9ad7e4542ce4c82fd9dbe1c Mon Sep 17 00:00:00 2001 From: cidrblock Date: Thu, 7 Apr 2022 03:29:20 -0700 Subject: [PATCH 7/8] Rebase --- .../{pre-commit-updates.yml => enable_upgrade_black.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename changelogs/fragments/{pre-commit-updates.yml => enable_upgrade_black.yml} (53%) diff --git a/changelogs/fragments/pre-commit-updates.yml b/changelogs/fragments/enable_upgrade_black.yml similarity index 53% rename from changelogs/fragments/pre-commit-updates.yml rename to changelogs/fragments/enable_upgrade_black.yml index 8a06961..fe6fc5f 100644 --- a/changelogs/fragments/pre-commit-updates.yml +++ b/changelogs/fragments/enable_upgrade_black.yml @@ -1,4 +1,4 @@ --- trivial: + - Enable black via pre-commit.ci - Update black version to latest - - Exempt update-docs from pre-commit.ci From d1d12d4d0d66074628653d5ea6eb651ba1fd36ba Mon Sep 17 00:00:00 2001 From: cidrblock Date: Thu, 7 Apr 2022 03:30:32 -0700 Subject: [PATCH 8/8] Rebase --- .pre-commit-config.yaml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d9be52c..7b8bdb8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,10 @@ --- -<<<<<<< HEAD ci: skip: # pre-commit.ci has trouble with this one - update-docs - - black - end-of-file-fixer - trailing-whitespace -||||||| parent of 681ca40 (No update docs) -======= -ci: - skip: - # pre-commit.ci has trouble with this one - - update-docs ->>>>>>> 681ca40 (No update docs) repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.1.0