@@ -643,11 +643,13 @@ def mutate(x):
643643
644644@pytest .mark .skipif (geopandas is None , reason = "geopandas is not available" )
645645def test_inspect_geopandas_dataframe () -> None :
646- p1 = Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 )]) # type: ignore
647- p2 = Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 ), (0 , 1 )]) # type: ignore
648- p3 = Polygon ([(2 , 0 ), (3 , 0 ), (3 , 1 ), (2 , 1 )]) # type: ignore
646+ assert Polygon
647+ assert geopandas
648+ p1 = Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 )])
649+ p2 = Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 ), (0 , 1 )])
650+ p3 = Polygon ([(2 , 0 ), (3 , 0 ), (3 , 1 ), (2 , 1 )])
649651
650- value = geopandas .GeoDataFrame ({"g" : geopandas .GeoSeries ([p1 , p2 , p3 ]), "data" : [0 , 1 , 2 ]}) # type: ignore
652+ value = geopandas .GeoDataFrame ({"g" : geopandas .GeoSeries ([p1 , p2 , p3 ]), "data" : [0 , 1 , 2 ]})
651653
652654 rows , cols = value .shape
653655
@@ -725,11 +727,13 @@ def mutate(x):
725727
726728@pytest .mark .skipif (geopandas is None , reason = "geopandas is not available" )
727729def test_inspect_geopandas_series () -> None :
728- value = geopandas .GeoSeries ( # type: ignore
730+ assert Polygon
731+ assert geopandas
732+ value = geopandas .GeoSeries (
729733 [
730- Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 )]), # type: ignore
731- Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 ), (0 , 1 )]), # type: ignore
732- Polygon ([(2 , 0 ), (3 , 0 ), (3 , 1 ), (2 , 1 )]), # type: ignore
734+ Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 )]),
735+ Polygon ([(0 , 0 ), (1 , 0 ), (1 , 1 ), (0 , 1 )]),
736+ Polygon ([(2 , 0 ), (3 , 0 ), (3 , 1 ), (2 , 1 )]),
733737 ]
734738 )
735739 (rows ,) = value .shape
@@ -888,12 +892,13 @@ def test_get_child(value: Any, key: Any, expected: Any) -> None:
888892@pytest .mark .skipif (sys .version_info < (3 , 10 ), reason = "requires Python 3.10 or higher" )
889893@pytest .mark .skipif (ibis is None , reason = "ibis not available" )
890894def test_inspect_ibis_exprs () -> None :
895+ assert ibis
891896 # Make sure we don't return an executed repr
892- ibis .options .interactive = True # type: ignore
897+ ibis .options .interactive = True
893898
894899 test_df = pd .DataFrame ({"a" : [1 , 2 , 1 , 1 , 2 ], "b" : ["foo" , "bar" , "baz" , "qux" , None ]})
895900 _ , columns = test_df .shape
896- t = ibis .memtable (test_df , name = "df" ) # type: ignore
901+ t = ibis .memtable (test_df , name = "df" )
897902 table_type = "ibis.Table"
898903
899904 verify_inspector (
@@ -931,21 +936,16 @@ def test_inspect_ibis_exprs() -> None:
931936@pytest .mark .parametrize (
932937 ("value" , "expected" ),
933938 [
934- (lambda : np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ]], dtype = "int64" ), 48 ),
935- pytest .param (
936- lambda : torch .Tensor ([[1 , 2 , 3 ], [4 , 5 , 6 ]]), # type: ignore
937- 24 ,
938- marks = pytest .mark .skipif (torch is None , reason = "torch not available" ),
939- ),
940- (lambda : pd .Series ([1 , 2 , 3 , 4 ]), 32 ),
941- (lambda : pl .Series ([1 , 2 , 3 , 4 ]), 32 ),
942- (lambda : pd .DataFrame ({"a" : [1 , 2 ], "b" : ["3" , "4" ]}), 4 ),
943- (lambda : pl .DataFrame ({"a" : [1 , 2 ], "b" : ["3" , "4" ]}), 4 ),
944- (lambda : pd .Index ([0 , 1 ]), 16 ),
939+ (np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ]], dtype = "int64" ), 48 ),
940+ (torch .Tensor ([[1 , 2 , 3 ], [4 , 5 , 6 ]]) if torch else None , 24 ),
941+ (pd .Series ([1 , 2 , 3 , 4 ]), 32 ),
942+ (pl .Series ([1 , 2 , 3 , 4 ]), 32 ),
943+ (pd .DataFrame ({"a" : [1 , 2 ], "b" : ["3" , "4" ]}), 4 ),
944+ (pl .DataFrame ({"a" : [1 , 2 ], "b" : ["3" , "4" ]}), 4 ),
945+ (pd .Index ([0 , 1 ]), 16 ),
945946 ],
946947)
947- def test_arrays_maps_get_size (value : Callable , expected : int ) -> None :
948- value = value ()
948+ def test_arrays_maps_get_size (value : Any , expected : int ) -> None :
949949 if value is None :
950950 return
951951 inspector = get_inspector (value )
@@ -959,53 +959,52 @@ class VeryLongClassNameThatShouldDefinitelyBeTruncatedBecauseItIsWayTooLong:
959959@pytest .mark .parametrize (
960960 "value" ,
961961 [
962- pytest .param (lambda : "The quick brown fox jumps over the lazy dog" , id = "string" ),
963- pytest .param (lambda : sys .maxsize * 100 , id = "int" ),
964- pytest .param (lambda : sys .float_info .max , id = "float" ),
965- pytest .param (lambda : complex (sys .float_info .min , sys .float_info .max ), id = "complex" ),
962+ pytest .param ("The quick brown fox jumps over the lazy dog" , id = "string" ),
963+ pytest .param (sys .maxsize * 100 , id = "int" ),
964+ pytest .param (sys .float_info .max , id = "float" ),
965+ pytest .param (complex (sys .float_info .min , sys .float_info .max ), id = "complex" ),
966966 pytest .param (
967- lambda : VeryLongClassNameThatShouldDefinitelyBeTruncatedBecauseItIsWayTooLong ,
967+ VeryLongClassNameThatShouldDefinitelyBeTruncatedBecauseItIsWayTooLong ,
968968 id = "class" ,
969969 ),
970- pytest .param (lambda : b"The quick brown fox jumps over the lazy dog" , id = "bytes" ),
970+ pytest .param (b"The quick brown fox jumps over the lazy dog" , id = "bytes" ),
971+ pytest .param (bytearray (b"The quick brown fox jumps over the lazy dog" ), id = "bytearray" ),
972+ pytest .param (set (range (20 )), id = "set" ),
973+ pytest .param (frozenset (range (20 )), id = "frozenset" ),
974+ pytest .param (list (range (20 )), id = "list" ),
975+ pytest .param (LIST_WITH_CYCLE , id = "list_cycle" ),
976+ pytest .param (range (12345678901 ), id = "range" ),
977+ pytest .param (L (range (20 )), id = "fastcore_list" ),
978+ pytest .param (FASTCORE_LIST_WITH_CYCLE , id = "fastcore_list_cycle" ),
979+ pytest .param ({str (i ): i for i in range (20 )}, id = "map" ),
980+ pytest .param (MAP_WITH_CYCLE , id = "map_cycle" ),
971981 pytest .param (
972- lambda : bytearray (b"The quick brown fox jumps over the lazy dog" ), id = "bytearray"
973- ),
974- pytest .param (lambda : set (range (20 )), id = "set" ),
975- pytest .param (lambda : frozenset (range (20 )), id = "frozenset" ),
976- pytest .param (lambda : list (range (20 )), id = "list" ),
977- pytest .param (lambda : LIST_WITH_CYCLE , id = "list_cycle" ),
978- pytest .param (lambda : range (12345678901 ), id = "range" ),
979- pytest .param (lambda : L (range (20 )), id = "fastcore_list" ),
980- pytest .param (lambda : FASTCORE_LIST_WITH_CYCLE , id = "fastcore_list_cycle" ),
981- pytest .param (lambda : {str (i ): i for i in range (20 )}, id = "map" ),
982- pytest .param (lambda : MAP_WITH_CYCLE , id = "map_cycle" ),
983- pytest .param (
984- lambda : datetime .datetime (2021 , 1 , 1 , 1 , 23 , 45 , tzinfo = datetime .timezone .utc ),
982+ datetime .datetime (2021 , 1 , 1 , 1 , 23 , 45 , tzinfo = datetime .timezone .utc ),
985983 id = "timestamp_datetime" ,
986984 ),
987- pytest .param (lambda : pd .Timestamp ("2021-01-01 01:23:45" ), id = "timestamp_pandas" ),
988- pytest .param (lambda : pd .Index (list (range (20 ))), id = "pandas_index" ),
989- pytest .param (lambda : pd .Series (list (range (20 ))), id = "pandas_series" ),
985+ pytest .param (pd .Timestamp ("2021-01-01 01:23:45" ), id = "timestamp_pandas" ),
986+ pytest .param (pd .Index (list (range (20 ))), id = "pandas_index" ),
987+ pytest .param (pd .Series (list (range (20 ))), id = "pandas_series" ),
990988 pytest .param (
991- lambda : pd .DataFrame ({"a" : list (range (20 )), "b" : list (range (20 ))}),
989+ pd .DataFrame ({"a" : list (range (20 )), "b" : list (range (20 ))}),
992990 id = "pandas_dataframe" ,
993991 ),
994- pytest .param (lambda : pl .Series (list (range (20 ))), id = "polars_series" ),
992+ pytest .param (pl .Series (list (range (20 ))), id = "polars_series" ),
995993 pytest .param (
996- lambda : pl .DataFrame ({"a" : list (range (20 )), "b" : list (range (20 ))}),
994+ pl .DataFrame ({"a" : list (range (20 )), "b" : list (range (20 ))}),
997995 id = "polars_dataframe" ,
998996 ),
999- pytest .param (lambda : np .ones ((20 , 20 )), id = "numpy_array" ),
997+ pytest .param (np .ones ((20 , 20 )), id = "numpy_array" ),
1000998 pytest .param (
1001- lambda : torch .ones ((20 , 20 )), # type: ignore
999+ torch .ones ((20 , 20 )) if torch else None ,
10021000 id = "torch_tensor" ,
10031001 marks = pytest .mark .skipif (torch is None , reason = "torch not available" ),
10041002 ),
10051003 ],
10061004)
10071005def test_truncated_display_value (value , snapshot , monkeypatch ) -> None :
1008- value = value ()
1006+ if value is None :
1007+ return
10091008 # Patch the maximum string length for faster and more readable tests.
10101009 monkeypatch .setattr (inspectors , "MAX_ITEMS_BY_LEVEL" , (20 , 10 ))
10111010 monkeypatch .setattr (inspectors , "MAX_CHARACTERS" , 20 )
0 commit comments