diff --git a/pins/boards.py b/pins/boards.py index c1eeb2f2..6d47d3b4 100644 --- a/pins/boards.py +++ b/pins/boards.py @@ -392,6 +392,9 @@ def pin_write( "Use .pin_upload() to save a file as a pin." ) + if name is None: + raise ValueError("Pin name must be provided when writing a pin.") + return self._pin_store( x, name, diff --git a/pins/tests/test_boards.py b/pins/tests/test_boards.py index ee22bd3d..30d40ee2 100644 --- a/pins/tests/test_boards.py +++ b/pins/tests/test_boards.py @@ -179,6 +179,17 @@ def test_board_pin_write_force_identical_write_msg( assert len(versions) == 1 +@skip_if_dbc +def test_board_pin_write_no_name(board, tmp_path): + df = pd.DataFrame({"x": [1, 2, 3]}) + + path = tmp_path.joinpath("data.csv") + df.to_csv(path, index=False) + + with pytest.raises(ValueError, match=r"Pin name must be provided"): + board.pin_write(path) + + @skip_if_dbc def test_board_pin_download(board_with_cache, tmp_path): # create and save data