PrefectHQ
prefect
BlogDocsChangelog

feat: add generic typing support for Variable.get method

#19764Merged
Comparing
devin/1765568895-variable-generic-typing
(
a95c98a
) with
main
(
57d6b87
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
462.5 µs462.5 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s

Ignored

bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+3%
32.6 ms31.8 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+26%
18.4 ms14.7 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-8%
5.3 ms5.8 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
107.6 ms107.6 ms
bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
1.1 s1.1 s
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-2%
167.2 ms171.3 ms

Commits

Click on a commit to change the comparison range
Base
main
57d6b87
0%
feat: add generic typing support for Variable.get method This adds optional explicit typing for the Variable.get and Variable.aget methods, allowing users to declare the expected type when retrieving a variable: var = Variable[str].get('my_variable') The implementation: - Makes Variable class generic with TypeVar T bounded to StrictVariableValue - Uses TypeVar default for backward compatibility (unparameterized Variable still works) - Adds overloads for get/aget to properly type the return value based on whether a default is provided - Both sync (get) and async (aget) methods support the same typing behavior Closes #19752 Co-Authored-By: Nate Nowack <nate@prefect.io>
a95c98a
3 days ago
by devin-ai-integration[bot]
© 2025 CodSpeed Technology
Home Terms Privacy Docs