cast replacements can be replace somewhat with 'isinstance' but normally you would have to use a full def to check for contents of the field, but this will give you an idea. You would have to add the quote thingys to make it a query string, but you can see the idea for a check
a = ["40", 30, "20", 10, '1']
for i in a:
print("{} < 70".format([i, int(i)][isinstance(i, str)]))
40 < 70
30 < 70
20 < 70
10 < 70
1 < 70
so 'i' in the above would simply be the fieldname (in ! ! )and you would skip the print of course. There a lots of cavaets to this however.
For example
int("1.23")
Traceback (most recent call last):
File "<ipython-input-24-84a3541b8dc8>", line 1, in <module>
int("1.23")
ValueError: invalid literal for int() with base 10: '1.23'