وَإِمَّا تَخَافَنَّ مِن قَوْمٍ خِيَانَةًۭ فَٱنۢبِذْ إِلَيْهِمْ عَلَىٰ سَوَآءٍ ۚ إِنَّ ٱللَّهَ لَا يُحِبُّ ٱلْخَآئِنِينَ
“Indeed, the worst of all beings in the Sight of Allah are those who persist in disbelief, never to have faith — [namely] those with whom you [O Prophet] have entered into treaties, but they violate them every time, not fearing the consequences. If you ever encounter them in battle, make a fearsome example of them, so perhaps those who would follow them may be deterred. And if you [O Prophet] see signs of betrayal by a people, respond by openly terminating your treaty with them. Surely, Allah does not like those who betray.”
Surah al-Anfal was revealed on the plains of Badr regarding the battle and its aftermath.
This ayah (Q8:58, on openly renouncing a treaty when treachery is feared) is the principle applied to expelling Banu Qaynuqa after they broke their covenant with the Prophet ﷺ, described at this event.