3939 SerDeInfo ,
4040 SkewedInfo ,
4141 StorageDescriptor ,
42+ )
43+ from hive_metastore .v4 .ttypes import (
4244 Database as HiveDatabase ,
45+ )
46+ from hive_metastore .v4 .ttypes import (
4347 Table as HiveTable ,
4448)
4549
@@ -254,8 +258,7 @@ def test_no_uri_supplied() -> None:
254258
255259
256260def test_check_number_of_namespaces (table_schema_simple : Schema ) -> None :
257- _HiveClient ._get_hive_version = MagicMock ()
258- _HiveClient ._get_hive_version .return_value = 3
261+ _HiveClient ._get_hive_version = MagicMock (return_value = 3 ) # type: ignore
259262 catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
260263
261264 with pytest .raises (ValueError ):
@@ -282,8 +285,7 @@ def test_create_table(
282285
283286 catalog ._client = MagicMock ()
284287 catalog ._client .__enter__ ().create_table .return_value = None
285- catalog ._get_hive_table = MagicMock ()
286- catalog ._get_hive_table .return_value = hive_table
288+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
287289 catalog ._client .__enter__ ().get_database .return_value = hive_database
288290 catalog .create_table (("default" , "table" ), schema = table_schema_with_all_types , properties = {"owner" : "javaberg" })
289291
@@ -462,8 +464,7 @@ def test_create_table_with_given_location_removes_trailing_slash(
462464
463465 catalog ._client = MagicMock ()
464466 catalog ._client .__enter__ ().create_table .return_value = None
465- catalog ._get_hive_table = MagicMock ()
466- catalog ._get_hive_table .return_value = hive_table
467+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
467468 catalog ._client .__enter__ ().get_database .return_value = hive_database
468469 catalog .create_table (
469470 ("default" , "table" ), schema = table_schema_with_all_types , properties = {"owner" : "javaberg" }, location = f"{ location } /"
@@ -636,7 +637,7 @@ def test_create_v1_table(table_schema_simple: Schema, hive_database: HiveDatabas
636637 catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
637638
638639 catalog ._client = MagicMock ()
639- catalog ._get_hive_table = MagicMock ()
640+ catalog ._get_hive_table = MagicMock () # type: ignore
640641 catalog ._client .__enter__ ().create_table .return_value = None
641642 catalog ._get_hive_table .return_value = hive_table
642643 catalog ._client .__enter__ ().get_database .return_value = hive_database
@@ -689,8 +690,7 @@ def test_load_table(hive_table: HiveTable) -> None:
689690 catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
690691
691692 catalog ._client = MagicMock ()
692- catalog ._get_hive_table = MagicMock ()
693- catalog ._get_hive_table .return_value = hive_table
693+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
694694 table = catalog .load_table (("default" , "new_tabl2e" ))
695695
696696 catalog ._get_hive_table .assert_called_with (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" )
@@ -790,8 +790,7 @@ def test_load_table_from_self_identifier(hive_table: HiveTable) -> None:
790790 catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
791791
792792 catalog ._client = MagicMock ()
793- catalog ._get_hive_table = MagicMock ()
794- catalog ._get_hive_table .return_value = hive_table
793+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
795794 intermediate = catalog .load_table (("default" , "new_tabl2e" ))
796795 table = catalog .load_table (intermediate .name ())
797796
@@ -896,8 +895,7 @@ def test_rename_table(hive_table: HiveTable) -> None:
896895 renamed_table .tableName = "new_tabl3e"
897896
898897 catalog ._client = MagicMock ()
899- catalog ._get_hive_table = MagicMock ()
900- catalog ._get_hive_table .side_effect = [hive_table , renamed_table ]
898+ catalog ._get_hive_table = MagicMock (side_effect = [hive_table , renamed_table ]) # type: ignore
901899 catalog ._client .__enter__ ().alter_table_with_environment_context .return_value = None
902900
903901 from_identifier = ("default" , "new_tabl2e" )
@@ -906,7 +904,10 @@ def test_rename_table(hive_table: HiveTable) -> None:
906904
907905 assert table .name () == to_identifier
908906
909- calls = [call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ), call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" )]
907+ calls = [
908+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ),
909+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" ),
910+ ]
910911 catalog ._get_hive_table .assert_has_calls (calls )
911912 catalog ._client .__enter__ ().alter_table_with_environment_context .assert_called_with (
912913 dbname = "default" ,
@@ -920,8 +921,7 @@ def test_rename_table_from_self_identifier(hive_table: HiveTable) -> None:
920921 catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
921922
922923 catalog ._client = MagicMock ()
923- catalog ._get_hive_table = MagicMock ()
924- catalog ._get_hive_table .return_value = hive_table
924+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
925925
926926 from_identifier = ("default" , "new_tabl2e" )
927927 from_table = catalog .load_table (from_identifier )
@@ -938,7 +938,10 @@ def test_rename_table_from_self_identifier(hive_table: HiveTable) -> None:
938938
939939 assert table .name () == to_identifier
940940
941- calls = [call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ), call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" )]
941+ calls = [
942+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ),
943+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" ),
944+ ]
942945 catalog ._get_hive_table .assert_has_calls (calls )
943946 catalog ._client .__enter__ ().alter_table_with_environment_context .assert_called_with (
944947 dbname = "default" ,
@@ -1024,7 +1027,7 @@ def test_list_tables(hive_table: HiveTable) -> None:
10241027
10251028 catalog ._client = MagicMock ()
10261029 catalog ._client .__enter__ ().get_all_tables .return_value = ["table1" , "table2" , "table3" , "table4" ]
1027- catalog ._get_table_objects_by_name = MagicMock ()
1030+ catalog ._get_table_objects_by_name = MagicMock () # type: ignore
10281031 catalog ._get_table_objects_by_name .return_value = [tbl1 , tbl2 , tbl3 , tbl4 ]
10291032
10301033 got_tables = catalog .list_tables ("database" )
@@ -1061,8 +1064,7 @@ def test_drop_table_from_self_identifier(hive_table: HiveTable) -> None:
10611064 catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
10621065
10631066 catalog ._client = MagicMock ()
1064- catalog ._get_hive_table = MagicMock ()
1065- catalog ._get_hive_table .return_value = hive_table
1067+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
10661068 table = catalog .load_table (("default" , "new_tabl2e" ))
10671069
10681070 catalog ._client .__enter__ ().get_all_databases .return_value = ["namespace1" , "namespace2" ]
0 commit comments