Force developers to use predefined list of attributes as function argument

How do I prevent developers from using get_tax() function with literal tax argument like get_tax(1000, 0.23) and force them to use predefined list?

class TaxRates:
    vat=0.23
    pit=0.15
    
def get_tax(price, tax):
    return price*tax

get_tax(1000, TaxRates.vat)  # should succeed
get_tax(1000, 0.23)  # should fail

Or is there better approach to go about this?

Answer

Something like the following should work, rather than pass the tax as a float pass a string or constant that can be looked up against the valid options. Using this the only valid values are “vat” or “pit”

An Enum would probably work too if you wanted to have the taxes in a structure as before

VAT = 'vat'
PIT = 'pit'
tax_rates = {
    VAT: 0.23,
    PIT: 0.15
}
    
def get_tax(price, tax):
    try:
        rate = tax_rates[tax]
    except KeyError:
        raise ValueError(f'Unknown tax "{tax}"')
    return price * rate

get_tax(1000, VAT)