message: fix(api): delete legacy deck calibration file
diff: remove single or multiple calibration files from the
  file system.
  """
  +# TODO(mc, 2022-06-08): this module has no unit tests
  +# add tests before making any additional changes
  from pathlib import Path
  from . import types as local_types, file_operators as io
  @@ -166,11 +168,14 @@ def delete_robot_deck_attitude() -> None:
  """
  Delete the robot deck attitude calibration.
  """
  -
  + legacy_deck_calibration_file = config.get_opentrons_path("deck_calibration_file")
  robot_dir = config.get_opentrons_path("robot_calibration_dir")
  gantry_path = robot_dir / "deck_calibration.json"
  - if gantry_path.exists():
  - gantry_path.unlink()
  +
  + # TODO(mc, 2022-06-08): this leaves legacy deck calibration backup files in place
  + # we should eventually clean them up, too, because they can really crowd /data/
  + _delete_file(legacy_deck_calibration_file)
  + _delete_file(gantry_path)
  def delete_gripper_calibration_file(gripper: str) -> None:
  @@ -196,3 +201,12 @@ def clear_gripper_calibration_offsets() -> None:
  _remove_json_files_in_directories(offset_dir)
  except FileNotFoundError:
  pass
  +
  +
  +# TODO(mc, 2022-06-07): replace with Path.unlink(missing_ok=True)
  +# when we are on Python >= 3.8
  +def _delete_file(path: Path) -> None:
  + try:
  + path.unlink()
  + except FileNotFoundError:
  + pass
  