pip install python_arptable
from typing import Optional
from python_arptable import get_arp_table
def get_ip_by_mac(macaddr: str) -> Optional[str]:
if record := next(filter(lambda i: i['HW address'].lower() == macaddr.lower(), get_arp_table()), None):
return record['IP address']
print(get_ip_by_mac('00:50:56:96:31:06')) # 10.0.20.91