Avatar for the PrefectHQ user
PrefectHQ
prefect
BlogDocsChangelog

Fix #17354: Preserve class binding in classmethod flows when using

#17647
Comparing
vilhenad:fix-classmethod-flow-bug-17354
(
19d765a
) with
main
(
5ab6871
)
CodSpeed Performance Gauge
0%
Improvements
0
Regressions
0
Untouched
2
New
0
Dropped
0
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py::bench_task_decorator
CodSpeed Performance Gauge
0%
447 µs
446.5 µs
bench_import_prefect_flow
benches/bench_import.py::bench_import_prefect_flow
CodSpeed Performance Gauge
0%
1.4 s
1.4 s

Ignored

bench_flow_call[options0]Ignored
benches/bench_flows.py::bench_flow_call[options0]
CodSpeed Performance Gauge
0%
157.7 ms
158 ms
bench_flow_call[options1]Ignored
benches/bench_flows.py::bench_flow_call[options1]
CodSpeed Performance Gauge
-1%
106.6 ms
107.4 ms
bench_flow_decoratorIgnored
benches/bench_flows.py::bench_flow_decorator
CodSpeed Performance Gauge
-3%
4.8 ms
4.9 ms
bench_import_prefectIgnored
benches/bench_import.py::bench_import_prefect
CodSpeed Performance Gauge
0%
2.6 ms
2.6 ms
bench_task_callIgnored
benches/bench_tasks.py::bench_task_call
CodSpeed Performance Gauge
-1%
156.9 ms
157.8 ms
bench_task_submitIgnored
benches/bench_tasks.py::bench_task_submit
CodSpeed Performance Gauge
×2.5
10.2 ms
4.1 ms

Commits

Click on a commit to change the comparison range
Base
main
5ab6871
0%
Fix #17354: Preserve class binding in classmethod flows when using .with_options() Classmethod flows were losing their cls inheritance structure when copied with .with_options(), causing them to default to the base class implementation. This was particularly evident when subclassing (e.g., ChildProcessor.process would incorrectly use BaseProcessor.get_multiplier). The fix ensures proper context preservation by: 1. Creating deep copies of the function for each bound flow 2. Maintaining independent __prefect_self__ references 3. Preserving all function attributes during copying Added test cases verify: - Classmethod inheritance is maintained after .with_options() - Instance methods retain their proper self context - Multiple bound flows don't interfere with each other
19d765a
6 days ago
by vilhenad
© 2025 CodSpeed Technology
Home Terms PrivacyDocs