Coverage for pysource_codegen/_limits.py: 100%
27 statements
« prev ^ index » next coverage.py v7.5.3, created at 2024-06-13 21:17 +0200
« prev ^ index » next coverage.py v7.5.3, created at 2024-06-13 21:17 +0200
1def calc_f_string_expr_limit():
2 n = 0
3 s = "1"
4 while True:
5 for q in ("'", '"', '"""', "'''"):
6 ns = "f" + q + "{" + s + "}" + q
8 try:
9 eval(ns)
10 s = ns
11 break
12 except:
13 continue
14 else:
15 return n
16 n += 1
19def calc_f_string_format_limit():
20 n = 0
21 s = "{1}"
22 while True:
23 s = "{2:" + s + "}"
25 try:
26 eval(f"f'{s}'")
27 except:
28 break
29 n += 1
31 return n
34f_string_expr_limit = calc_f_string_expr_limit()
35f_string_format_limit = calc_f_string_format_limit()