From c2a43596158140158618afae049fa4b9c7b23585 Mon Sep 17 00:00:00 2001 From: Aldrian Harjati Date: Mon, 21 Aug 2023 13:38:09 -0400 Subject: [PATCH] fix ruff issues --- src/tests/test_check_functions.py | 29 +++++++++++++++-------------- src/validator/global_data.py | 1 - src/validator/phase_validations.py | 27 ++++++++++++++------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/tests/test_check_functions.py b/src/tests/test_check_functions.py index 5d17d6f0..708c441d 100644 --- a/src/tests/test_check_functions.py +++ b/src/tests/test_check_functions.py @@ -298,7 +298,8 @@ def test_conditional_field_conflict_correct(self): def test_conditional_field_conflict_incorrect(self): # if ct_loan_term_flag != 900 then ct_loan_term must be blank - # in this test, ct_loan_term_flag is not 900 and ct_loan_term is NOT blank, so must return False + # in this test, ct_loan_term_flag is not 900 and ct_loan_term is + # NOT blank, so must return False series = pd.Series(["36"], name="ct_loan_term", index=[2]) condition_values: set[str] = {"900"} @@ -652,15 +653,15 @@ def test_with_valid_series(self): def test_with_multiple_valid_series(self): result = is_unique_column({"ABC123": self.series, "DEF456": self.other_series}) - assert result.values[0] == True and result.values[1] == True + assert bool(result.values[0]) is True and bool(result.values[1]) is True def test_with_invalid_series(self): result = is_unique_column({"ABC123": self.invalid_series}) - assert result.values.all() == False + assert bool(result.values.all()) is False def test_with_multiple_items_series(self): result = is_unique_column({"GHI123": self.multi_invalid_series}) - assert result.values.all() == False + assert bool(result.values.all()) is False def test_with_multiple_invalid_series(self): result = is_unique_column( @@ -668,11 +669,11 @@ def test_with_multiple_invalid_series(self): ) # ALL rows should be FALSE assert ( - result.values[0] == False - and result.values[1] == False - and result.values[2] == False - and result.values[3] == False - and result.values[4] == False + bool(result.values[0]) is False + and bool(result.values[1]) is False + and bool(result.values[2]) is False + and bool(result.values[3]) is False + and bool(result.values[4]) is False ) def test_with_multiple_mix_series(self): @@ -681,9 +682,9 @@ def test_with_multiple_mix_series(self): ) # first two rows should be FALSE and last Row should be TRUE assert ( - result.values[0] == False - and result.values[1] == False - and result.values[2] == True + bool(result.values[0]) is False + and bool(result.values[1]) is False + and bool(result.values[2]) is True ) def test_with_blank_value_series(self): @@ -791,7 +792,7 @@ def test_with_incorrect_is_equal_and_not_equal_conditions(self): "field2": (1, True, "999"), "field3": (2, True, "0"), "field4": (3, False, ""), - "field4": (4, False, ""), + "field5": (4, False, ""), } series = pd.Series(["0"], name="num_principal_owners", index=[1]) @@ -867,7 +868,7 @@ def test_with_incorrect_values(self): string_contains( "000TESTFIUIDDONOTUSEXGXVID11XTC1", "000TESTFIUIDDONOTUSEXGX", - end_idx=20, + end_idx=23, ) is True ) diff --git a/src/validator/global_data.py b/src/validator/global_data.py index 69c1fc40..422851b2 100644 --- a/src/validator/global_data.py +++ b/src/validator/global_data.py @@ -1,5 +1,4 @@ import os -import re import sys import pandas as pd diff --git a/src/validator/phase_validations.py b/src/validator/phase_validations.py index 36bda0c9..05d9e571 100644 --- a/src/validator/phase_validations.py +++ b/src/validator/phase_validations.py @@ -75,8 +75,9 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): string_contains, name="uid.invalid_uid_lei", description=( - "The first 20 characters of the 'unique identifier' should match " - "the Legal Entity Identifier (LEI) for the financial institution." + "The first 20 characters of the 'unique identifier' " + "should match the Legal Entity Identifier (LEI) for " + "the financial institution." ), element_wise=True, containing_value=lei, @@ -137,8 +138,8 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): is_valid_enum, name="ct_credit_product.invalid_enum_value", description=( - "'Credit product' must equal 1, 2, 3, 4, 5, 6, 7, 8, " - "977, or 988." + "'Credit product' must equal 1, 2, 3, 4, 5, 6, " + "7, 8, 977, or 988." ), element_wise=True, accepted_values=[ @@ -950,11 +951,11 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): description=( "When 'interest rate type' does not equal 1" " (adjustable interest rate, no initial rate period)," - " 3 (initial rate period > 12 months, adjustable interest rate)," - " or 5 (initial rate period <= 12 months, variable interest" - " rate), 'adjustable rate transaction: margin' must be blank." - " When 'interest rate type' equals 1, 3, or 5, 'variable" - " rate transaction: margin' must not be blank." + " 3 (initial rate period > 12 months, adjustable interest " + "rate), or 5 (initial rate period <= 12 months, variable " + "interest rate), 'adjustable rate transaction: margin' must " + "be blank. When 'interest rate type' equals 1, 3, or 5, " + "'variable rate transaction: margin' must not be blank." ), groupby="pricing_interest_rate_type", condition_values={"1", "3", "5"}, @@ -978,8 +979,8 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): is_valid_enum, name="pricing_adj_index_name.invalid_enum_value", description=( - "'Adjustable rate transaction: index name' must equal 1, 2, 3, 4," - "5, 6, 7, 8, 9, 10, 977, or 999." + "'Adjustable rate transaction: index name' must equal " + "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 977, or 999." ), element_wise=True, accepted_values=[ @@ -1036,8 +1037,8 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): max_value=300, name="pricing_adj_index_name_ff.invalid_text_length", description=( - "'Adjustable rate transaction: index name: other' must not exceed" - "300 characters in length." + "'Adjustable rate transaction: index name: other' must " + "not exceed 300 characters in length." ), ), ],