From 7abca2b7bcdd4e176f05f803fd2fd3af76b12327 Mon Sep 17 00:00:00 2001 From: Stefan Ulbrich <6009224+StefanUlbrich@users.noreply.github.com> Date: Fri, 21 Apr 2023 15:04:40 +0200 Subject: [PATCH 1/5] Covnert newtypes to type aliases --- .../snowpark/_internal/type_utils.py | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/snowflake/snowpark/_internal/type_utils.py b/src/snowflake/snowpark/_internal/type_utils.py index e4e4cf6b043..5da71de23b6 100644 --- a/src/snowflake/snowpark/_internal/type_utils.py +++ b/src/snowflake/snowpark/_internal/type_utils.py @@ -622,14 +622,22 @@ def type_string_to_type_object(type_str: str) -> DataType: # Type hints -ColumnOrName = NewType("ColumnOrName", Union["snowflake.snowpark.column.Column", str]) -ColumnOrLiteralStr = NewType( - "ColumnOrLiteralStr", Union["snowflake.snowpark.column.Column", str] -) -ColumnOrSqlExpr = NewType( - "ColumnOrSqlExpr", Union["snowflake.snowpark.column.Column", str] -) -LiteralType = NewType("LiteralType", Union[VALID_PYTHON_TYPES_FOR_LITERAL_VALUE]) -ColumnOrLiteral = NewType( - "ColumnOrLiteral", Union["snowflake.snowpark.column.Column", LiteralType] -) + + +ColumnOrName = Union["snowflake.snowpark.column.Column", str] +ColumnOrLiteralStr = Union["snowflake.snowpark.column.Column", str] +ColumnOrSqlExpr = Union["snowflake.snowpark.column.Column", str] +LiteralType = Union[VALID_PYTHON_TYPES_FOR_LITERAL_VALUE] +ColumnOrLiteral = Union["snowflake.snowpark.column.Column", LiteralType] + +# ColumnOrName = NewType("ColumnOrName", Union["snowflake.snowpark.column.Column", str]) +# ColumnOrLiteralStr = NewType( +# "ColumnOrLiteralStr", Union["snowflake.snowpark.column.Column", str] +# ) +# ColumnOrSqlExpr = NewType( +# "ColumnOrSqlExpr", Union["snowflake.snowpark.column.Column", str] +# ) +# LiteralType = NewType("LiteralType", Union[VALID_PYTHON_TYPES_FOR_LITERAL_VALUE]) +# ColumnOrLiteral = NewType( +# "ColumnOrLiteral", Union["snowflake.snowpark.column.Column", LiteralType] +# ) From 45a0bdf039bce5dfe8d0777e7227de21dc7f5a33 Mon Sep 17 00:00:00 2001 From: Stefan Ulbrich <6009224+StefanUlbrich@users.noreply.github.com> Date: Fri, 21 Apr 2023 15:16:15 +0200 Subject: [PATCH 2/5] Remove commented code --- src/snowflake/snowpark/_internal/type_utils.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/snowflake/snowpark/_internal/type_utils.py b/src/snowflake/snowpark/_internal/type_utils.py index 5da71de23b6..0c9e79f4e0a 100644 --- a/src/snowflake/snowpark/_internal/type_utils.py +++ b/src/snowflake/snowpark/_internal/type_utils.py @@ -629,15 +629,3 @@ def type_string_to_type_object(type_str: str) -> DataType: ColumnOrSqlExpr = Union["snowflake.snowpark.column.Column", str] LiteralType = Union[VALID_PYTHON_TYPES_FOR_LITERAL_VALUE] ColumnOrLiteral = Union["snowflake.snowpark.column.Column", LiteralType] - -# ColumnOrName = NewType("ColumnOrName", Union["snowflake.snowpark.column.Column", str]) -# ColumnOrLiteralStr = NewType( -# "ColumnOrLiteralStr", Union["snowflake.snowpark.column.Column", str] -# ) -# ColumnOrSqlExpr = NewType( -# "ColumnOrSqlExpr", Union["snowflake.snowpark.column.Column", str] -# ) -# LiteralType = NewType("LiteralType", Union[VALID_PYTHON_TYPES_FOR_LITERAL_VALUE]) -# ColumnOrLiteral = NewType( -# "ColumnOrLiteral", Union["snowflake.snowpark.column.Column", LiteralType] -# ) From 31826fb96306129a332b06d663450c6d9f9ce1de Mon Sep 17 00:00:00 2001 From: Stefan Ulbrich <6009224+StefanUlbrich@users.noreply.github.com> Date: Fri, 21 Apr 2023 15:17:05 +0200 Subject: [PATCH 3/5] Remove newlines --- src/snowflake/snowpark/_internal/type_utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/snowflake/snowpark/_internal/type_utils.py b/src/snowflake/snowpark/_internal/type_utils.py index 0c9e79f4e0a..d9c61198fc8 100644 --- a/src/snowflake/snowpark/_internal/type_utils.py +++ b/src/snowflake/snowpark/_internal/type_utils.py @@ -622,8 +622,6 @@ def type_string_to_type_object(type_str: str) -> DataType: # Type hints - - ColumnOrName = Union["snowflake.snowpark.column.Column", str] ColumnOrLiteralStr = Union["snowflake.snowpark.column.Column", str] ColumnOrSqlExpr = Union["snowflake.snowpark.column.Column", str] From cf19c24424a2073b0fe754bb04881978a7c4bdaf Mon Sep 17 00:00:00 2001 From: Afroz Alam Date: Sat, 22 Apr 2023 18:21:25 -0700 Subject: [PATCH 4/5] give credits to stefan --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2abe83c37ab..97aef624acb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 1.5.0 (TBD) + +### New Features + +### Bug Fixes + +- Fixed type hint declaration for custom types - `ColumnOrName`, `ColumnOrLiteralStr`, `ColumnOrSqlExpr`, `LiteralType` and `ColumnOrLiteral` that were breaking `mypy` checks. Contributor: @StefanUlbrich. + ## 1.4.0 (TBD) ### New Features From b58af36b927933a39d5b07445a50005d39e92844 Mon Sep 17 00:00:00 2001 From: Afroz Alam Date: Fri, 28 Apr 2023 16:49:03 -0700 Subject: [PATCH 5/5] Update CHANGELOG.md remove shoutouts from changelog as it is not a consistent practice in the team --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a36cd79e8..810556635c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Bug Fixes -- Fixed type hint declaration for custom types - `ColumnOrName`, `ColumnOrLiteralStr`, `ColumnOrSqlExpr`, `LiteralType` and `ColumnOrLiteral` that were breaking `mypy` checks. Contributor: @StefanUlbrich. +- Fixed type hint declaration for custom types - `ColumnOrName`, `ColumnOrLiteralStr`, `ColumnOrSqlExpr`, `LiteralType` and `ColumnOrLiteral` that were breaking `mypy` checks. ## 1.4.0 (2023-04-24)