From 98e854ce8bf67ee9a9377ca75924f44d110289df Mon Sep 17 00:00:00 2001 From: SemyonSinchenko Date: Thu, 16 Nov 2023 19:55:50 +0000 Subject: [PATCH] Fix linter v2 On branch feature/fix-tests Changes to be committed: modified: pyproject.toml modified: quinn/extensions/column_ext.py modified: quinn/schema_helpers.py modified: quinn/split_columns.py --- pyproject.toml | 19 ++++++++++--------- quinn/extensions/column_ext.py | 2 +- quinn/schema_helpers.py | 9 ++++----- quinn/split_columns.py | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6da00031..b90b0cd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,15 +66,16 @@ select = ["ALL"] line-length = 150 ignore = [ "D100", - "D203", # Ignore blank line before summary of class - "D213", # Ignore multiline summary second line - "T201", # Allow print() in code. - "D401", # Docstrings should be in imperative modes - "D404", # Boring thing about how to write docsrings - "FBT001", # Boolean positional arg is OK - "FBT002", # Boolean default arg value is OK - "D205", # It is broken - "TCH003", # I have no idea what is it about + "D203", # Ignore blank line before summary of class + "D213", # Ignore multiline summary second line + "T201", # Allow print() in code. + "D401", # Docstrings should be in imperative modes + "D404", # Boring thing about how to write docsrings + "FBT001", # Boolean positional arg is OK + "FBT002", # Boolean default arg value is OK + "D205", # It is broken + "TCH003", # I have no idea what is it about + "PLC1901", # Strange thing ] extend-exclude = ["tests", "docs"] diff --git a/quinn/extensions/column_ext.py b/quinn/extensions/column_ext.py index 99b96982..f44ea006 100644 --- a/quinn/extensions/column_ext.py +++ b/quinn/extensions/column_ext.py @@ -63,7 +63,7 @@ def isNullOrBlank(self: Column) -> Column: blank characters, or ``False`` otherwise. :rtype: Column """ - return (self.isNull()) | (trim(self) == "") # noqa: PLC1901 + return (self.isNull()) | (trim(self) == "") def isNotIn(self: Column, _list: list[Any]) -> Column: diff --git a/quinn/schema_helpers.py b/quinn/schema_helpers.py index 6fe382d3..9542a377 100644 --- a/quinn/schema_helpers.py +++ b/quinn/schema_helpers.py @@ -42,12 +42,11 @@ def print_schema_as_code(dtype: T.DataType) -> str: elif isinstance(dtype, T.DecimalType): res.append(f"DecimalType({dtype.precision}, {dtype.scale})") - else: + elif str(dtype).endswith("()"): # PySpark 3.3+ - if str(dtype).endswith("()"): # noqa: PLR5501 - res.append(str(dtype)) - else: - res.append(f"{dtype}()") + res.append(str(dtype)) + else: + res.append(f"{dtype}()") return "".join(res) diff --git a/quinn/split_columns.py b/quinn/split_columns.py index 43f6d982..7b7186ba 100644 --- a/quinn/split_columns.py +++ b/quinn/split_columns.py @@ -68,7 +68,7 @@ def _num_delimiter(col_value1: str) -> int: # If the length of split_value is same as new_col_names, check if any of the split values is None or empty string elif any( # noqa: RET506 - x is None or x.strip() == "" for x in split_value[: len(new_col_names)] # noqa: PLC1901 + x is None or x.strip() == "" for x in split_value[: len(new_col_names)] ): msg = "Null or empty values are not accepted for columns in strict mode" raise ValueError( @@ -93,7 +93,7 @@ def _num_delimiter(col_value1: str) -> int: if mode == "strict": # Create an array of select expressions to create new columns from the split values select_exprs = [ - when(split_col_expr.getItem(i) != "", split_col_expr.getItem(i)).alias( # noqa: PLC1901 + when(split_col_expr.getItem(i) != "", split_col_expr.getItem(i)).alias( new_col_names[i], ) for i in range(len(new_col_names))