The description of the Defensive Duelist feat says (PHB, p. 165):
When you are wielding a finesse weapon with which you are proficient and another creature hits you with a melee attack, you can use your reaction to add your proficiency bonus to your AC for that attack, potentially causing the attack to miss you.
Assume a spellcaster who has the Defensive Duelist feat is holding a dagger and an arcane focus. For the duration of combat, they cast spells and never make a melee weapon attack. Do they still gain the benefit of the feat?