From 8b64e539859e4f674cd99cca93576354b8d3ac07 Mon Sep 17 00:00:00 2001 From: Bernardo Decco Date: Thu, 23 Sep 2021 15:58:59 -0300 Subject: [PATCH] Re-enable important py3k checks for fault Re-enabling some of the disabled tox warnings present on the pylint.rc file Re-enabling: W1641: eq-without-hash W1619: old-division Test Plan: Sanity test run on AIO-SX: PASS: test_system_health_pre_session[pods] PASS: test_system_health_pre_session[alarms] PASS: test_system_health_pre_session[system_apps] PASS: test_wr_analytics[deploy_and_remove] PASS: test_horizon_host_inventory_display PASS: test_lock_unlock_host[controller] PASS: test_pod_to_pod_connection PASS: test_pod_to_service_connection PASS: test_host_to_service_connection Story: 2006796 Task: 43429 Signed-off-by: Bernardo Decco Change-Id: I333a936bd2ee10c19e5d9e6dae23a0b9be6fc2a1 --- fm-rest-api/fm/fm/api/controllers/v1/base.py | 3 +++ pylint.rc | 10 ++++------ python-fmclient/fmclient/fmclient/common/base.py | 3 +++ .../fmclient/fmclient/common/wrapping_formatters.py | 10 +++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/fm-rest-api/fm/fm/api/controllers/v1/base.py b/fm-rest-api/fm/fm/api/controllers/v1/base.py index 761e3982..fa2dbca1 100644 --- a/fm-rest-api/fm/fm/api/controllers/v1/base.py +++ b/fm-rest-api/fm/fm/api/controllers/v1/base.py @@ -127,5 +127,8 @@ class Version(object): def __eq__(self, other): return (self.major, self.minor) == (other.major, other.minor) + def __hash__(self): + return hash((self.major, self.minor)) + def __ne__(self, other): return not self.__eq__(other) diff --git a/pylint.rc b/pylint.rc index 6a9f5bde..1d879ad3 100755 --- a/pylint.rc +++ b/pylint.rc @@ -146,8 +146,6 @@ enable=E1603,E1609,E1610,E1602,E1606,E1608,E1607,E1605,E1604,E1601,E1611,W1652, # W0703 broad-except # W1401 anomalous-backslash-in-string # W1618: no-absolute-import -# W1619: old-division -# W1641: eq-without-hash # E are error codes # E0604 invalid-all-object # E1101 no-member @@ -157,10 +155,10 @@ enable=E1603,E1609,E1610,E1602,E1606,E1608,E1607,E1605,E1604,E1601,E1611,W1652, # NOTE: these are suppressed until py3 support merges: # W0143,W1505,E0604,E0611,E0702,E1136,E0401 disable=C, R, fixme, - W0102,W0106,W0107,W0110,W0201,W0212,W0221,W0223,W0231,W0237,W0235, - W0311,W0403,W0603,W0612,W0613,W0621,W0622,W0703,W1401, - W0143,W1505,W1618,W1619,W1641,E0604,E0611,E0702,E1136, - E0401,E0604,E1101,E1102,E1120,E1121 + W0102,W0106,W0107,W0110,W0201,W0212,W0221,W0223,W0231, + W0237,W0235,W0311,W0403,W0603,W0612,W0613,W0621,W0622, + W0703,W1401,W0143,W1505,W1618,E0604,E0611,E0702,E1136, + E0401,E0604,E1101,E1102,E1120,E1121 [REPORTS] # Set the output format. Available formats are text, parseable, colorized, msvs diff --git a/python-fmclient/fmclient/fmclient/common/base.py b/python-fmclient/fmclient/fmclient/common/base.py index 90cdee5e..5664dbb0 100644 --- a/python-fmclient/fmclient/fmclient/common/base.py +++ b/python-fmclient/fmclient/fmclient/common/base.py @@ -139,6 +139,9 @@ class Resource(object): return self.id == other.id return self._info == other._info + def __hash__(self): + return hash((self._info, self.manager, self._loaded)) + def is_loaded(self): return self._loaded diff --git a/python-fmclient/fmclient/fmclient/common/wrapping_formatters.py b/python-fmclient/fmclient/fmclient/common/wrapping_formatters.py index 82f4732a..7d76d0e8 100644 --- a/python-fmclient/fmclient/fmclient/common/wrapping_formatters.py +++ b/python-fmclient/fmclient/fmclient/common/wrapping_formatters.py @@ -454,15 +454,15 @@ def build_column_stats_for_best_guess_formatting(objs, fields, field_labels, cus if value_width > self.max_width: self.max_width = value_width if self.count > 0: - self.average_width = float(self.total_width) / float(self.count) + self.average_width = float(self.total_width) / float(self.count) # pylint: disable=old-division def set_max_percent(self, max_total_width): if max_total_width > 0: - self.max_percent = float(self.max_width) / float(max_total_width) + self.max_percent = float(self.max_width) / float(max_total_width) # pylint: disable=old-division def set_avg_percent(self, avg_total_width): if avg_total_width > 0: - self.average_percent = float(self.average_width) / float(avg_total_width) + self.average_percent = float(self.average_width) / float(avg_total_width) # pylint: disable=old-division def __str__(self): return str([self.field, @@ -514,7 +514,7 @@ def build_best_guess_formatters_using_average_widths(objs, fields, field_labels, if total_avg_width <= 0: return format_spec for f in [ff for ff in fields if ff not in no_wrap_fields]: - format_spec[f] = float(column_info["stats"][f].average_width) / total_avg_width + format_spec[f] = float(column_info["stats"][f].average_width) / total_avg_width # pylint: disable=old-division custom_formatter = custom_formatters.get(f, None) if custom_formatter: format_spec[f] = {"formatter": custom_formatter, "wrapperFormatter": format_spec[f]} @@ -532,7 +532,7 @@ def build_best_guess_formatters_using_max_widths(objs, fields, field_labels, cus column_info = build_column_stats_for_best_guess_formatting(objs, fields, field_labels, custom_formatters) format_spec = {} for f in [ff for ff in fields if ff not in no_wrap_fields]: - format_spec[f] = float(column_info["stats"][f].max_width) / float(column_info["total_max_width"]) + format_spec[f] = float(column_info["stats"][f].max_width) / float(column_info["total_max_width"]) # pylint: disable=old-division custom_formatter = custom_formatters.get(f, None) if custom_formatter: format_spec[f] = {"formatter": custom_formatter, "wrapperFormatter": format_spec[f]}