File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 22
33
44def _assert_str_and_python_varname (name ):
5-
65 if not isinstance (name , str ):
76 raise TypeError (f"Expected a string for variable name, got { type (name ).__name__ } instead." )
87
@@ -11,7 +10,7 @@ def _assert_str_and_python_varname(name):
1110 if not name .isidentifier ():
1211 msg += "not a valid identifier. HINT: avoid using spaces, special characters, and starting with a number."
1312 raise ValueError (msg )
14-
13+
1514 if iskeyword (name ):
1615 msg += f"it is a reserved keyword. HINT: avoid using the following names: { ', ' .join (kwlist )} "
17- raise ValueError (msg )
16+ raise ValueError (msg )
Original file line number Diff line number Diff line change @@ -17,11 +17,11 @@ def test_field_init_param_types():
1717 grid = XGrid .from_dataset (data )
1818
1919 with pytest .raises (TypeError , match = "Expected a string for variable name, got int instead." ):
20- Field (name = 123 , data = data [' data_g' ], grid = grid )
20+ Field (name = 123 , data = data [" data_g" ], grid = grid )
2121
2222 for name in ["a b" , "123" , "while" ]:
2323 with pytest .raises (ValueError , match = r"Received invalid Python variable name.*" ):
24- Field (name = name , data = data [' data_g' ], grid = grid )
24+ Field (name = name , data = data [" data_g" ], grid = grid )
2525
2626 with pytest .raises (ValueError , match = "Expected `data` to be a uxarray.UxDataArray or xarray.DataArray" ):
2727 Field (name = "test" , data = 123 , grid = grid )
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def test_fieldset_add_constant(fieldset):
3838 fieldset .add_constant ("test_constant" , 1.0 )
3939 assert fieldset .test_constant == 1.0
4040
41+
4142def test_fieldset_add_constant_int_name (fieldset ):
4243 with pytest .raises (TypeError , match = "Expected a string for variable name, got int instead." ):
4344 fieldset .add_constant (123 , 1.0 )
You can’t perform that action at this time.
0 commit comments