From e15cb50766699d169ac3a478d986d1fc5f8289ca Mon Sep 17 00:00:00 2001 From: R-Palazzo <116157184+R-Palazzo@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:28:34 -0400 Subject: [PATCH] Fix lint + Pin ruff version (#900) --- pyproject.toml | 5 +++-- rdt/transformers/pii/anonymizer.py | 3 +-- tests/unit/test_hyper_transformer.py | 17 ++++++----------- tests/unit/transformers/pii/test_anonymizer.py | 2 +- tests/unit/transformers/test_base.py | 2 +- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 20f5775f..cf87df65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -203,10 +203,11 @@ select = [ # print statements "T201", # pandas-vet - "PD" + "PD", + # numpy 2.0 + "NPY201" ] ignore = [ - "E501", # pydocstyle "D107", # Missing docstring in __init__ "D417", # Missing argument descriptions in the docstring, this is a bug from pydocstyle: https://github.com/PyCQA/pydocstyle/issues/449 diff --git a/rdt/transformers/pii/anonymizer.py b/rdt/transformers/pii/anonymizer.py index 3f4d9fa0..9094217c 100644 --- a/rdt/transformers/pii/anonymizer.py +++ b/rdt/transformers/pii/anonymizer.py @@ -133,8 +133,7 @@ def __init__( self.provider_name = provider_name if provider_name else 'BaseProvider' if self.provider_name != 'BaseProvider' and function_name is None: raise TransformerInputError( - 'Please specify the function name to use from the ' - f"'{self.provider_name}' provider." + f"Please specify the function name to use from the '{self.provider_name}' provider." ) self.function_name = function_name if function_name else 'lexify' diff --git a/tests/unit/test_hyper_transformer.py b/tests/unit/test_hyper_transformer.py index dbdc2e80..6b5354cc 100644 --- a/tests/unit/test_hyper_transformer.py +++ b/tests/unit/test_hyper_transformer.py @@ -553,7 +553,7 @@ def test_validate_config_not_unique_field(self): # Run error_msg = re.escape( - 'Error: Invalid config. Please provide unique keys for the sdtypes ' 'and transformers.' + 'Error: Invalid config. Please provide unique keys for the sdtypes and transformers.' ) with pytest.raises(InvalidConfigError, match=error_msg): HyperTransformer._validate_config(config) @@ -858,8 +858,7 @@ def test_set_config_already_fitted(self, mock_warnings): # Assert expected_warnings_msg = ( - 'For this change to take effect, please refit your data using ' - "'fit' or 'fit_transform'." + "For this change to take effect, please refit your data using 'fit' or 'fit_transform'." ) mock_warnings.warn.assert_called_once_with(expected_warnings_msg) @@ -2511,8 +2510,7 @@ def test_update_transformers_fitted(self, mock_warnings): # Assert expected_message = ( - "For this change to take effect, please refit your data using 'fit' " - "or 'fit_transform'." + "For this change to take effect, please refit your data using 'fit' or 'fit_transform'." ) mock_warnings.warn.assert_called_once_with(expected_message) @@ -2921,8 +2919,7 @@ def test_update_sdtypes_fitted(self, mock_warnings, mock_logger): # Assert expected_message = ( - "For this change to take effect, please refit your data using 'fit' " - "or 'fit_transform'." + "For this change to take effect, please refit your data using 'fit' or 'fit_transform'." ) user_message = ( 'The transformers for these columns may change based on the new sdtype.\n' @@ -3470,8 +3467,7 @@ def test_remove_transformers_fitted(self, mock_warnings): # Assert expected_warnings_msg = ( - 'For this change to take effect, please refit your data using ' - "'fit' or 'fit_transform'." + "For this change to take effect, please refit your data using 'fit' or 'fit_transform'." ) mock_warnings.warn.assert_called_once_with(expected_warnings_msg) assert ht.field_transformers == { @@ -3558,8 +3554,7 @@ def test_remove_transformers_by_sdtype(self, mock_warnings): 'column3': None, } expected_warnings_msg = ( - 'For this change to take effect, please refit your data using ' - "'fit' or 'fit_transform'." + "For this change to take effect, please refit your data using 'fit' or 'fit_transform'." ) mock_warnings.warn.assert_called_once_with(expected_warnings_msg) diff --git a/tests/unit/transformers/pii/test_anonymizer.py b/tests/unit/transformers/pii/test_anonymizer.py index 32173664..05d3a14e 100644 --- a/tests/unit/transformers/pii/test_anonymizer.py +++ b/tests/unit/transformers/pii/test_anonymizer.py @@ -425,7 +425,7 @@ def test___init__no_function_name(self): """ # Run / Assert expected_message = ( - 'Please specify the function name to use from the ' "'credit_card' provider." + "Please specify the function name to use from the 'credit_card' provider." ) with pytest.raises(TransformerInputError, match=expected_message): AnonymizedFaker(provider_name='credit_card', locales=['en_US', 'fr_FR']) diff --git a/tests/unit/transformers/test_base.py b/tests/unit/transformers/test_base.py index 18aa8ac5..c91b411b 100644 --- a/tests/unit/transformers/test_base.py +++ b/tests/unit/transformers/test_base.py @@ -170,7 +170,7 @@ def test_get_input_sdtype_raises_warning(self, mock_get_supported_sdtypes): # Run expected_message = ( - '`get_input_sdtype` is deprecated. Please use ' '`get_supported_sdtypes` instead.' + '`get_input_sdtype` is deprecated. Please use `get_supported_sdtypes` instead.' ) with pytest.warns(FutureWarning, match=expected_message): input_sdtype = BaseTransformer.get_input_sdtype()