Skip to content

RxPY v5#743

Merged
dbrattli merged 19 commits intomasterfrom
fluent-style
Nov 11, 2025
Merged

RxPY v5#743
dbrattli merged 19 commits intomasterfrom
fluent-style

Conversation

@dbrattli
Copy link
Collaborator

@dbrattli dbrattli commented Nov 9, 2025

RxPY v5: Fluent Method Chaining Support

Summary

This release introduces fluent method chaining to RxPY while maintaining full backward compatibility with the existing pipe-based functional style. Both styles now work seamlessly together.

What's New

Dual Syntax Support - Use operators as methods OR functions:

Fluent style (NEW)

(
    rx.of(1, 2, 3, 4, 5)
    .map(lambda x: x * 2)
    .filter(lambda x: x > 5)
    .take(3)
    .subscribe(print)
)

Functional style (still works)

rx.of(1, 2, 3, 4, 5).pipe(
    ops.map(lambda x: x * 2),
    ops.filter(lambda x: x > 5),
    ops.take(3)
).subscribe(print)

Mix both styles freely

source.map(lambda x: x * 2).pipe(
    ops.filter(lambda x: x > 5),
    ops.take(3)
)

Current Progress

  • 90 operators implemented with method chaining support (54.9% complete)
  • Zero breaking changes - all existing code continues to work
  • Full type safety - strict pyright/mypy compliance
  • Complete documentation - all methods include both styles in examples
  • 1401 tests passing - comprehensive test coverage

Implementation Details

###Architecture:

Mixin-based organization (11 category-focused mixins)
Observable inherits all operator methods via multiple inheritance
Each method delegates to the corresponding operator function via pipe()

Categories Completed:

✅ Transformation (map, flat_map, scan, starmap, etc.)
✅ Filtering (filter, take, skip, distinct, etc.)
✅ Mathematical (count, sum, average, min, max)
✅ Conditional (take_while, skip_until, default_if_empty)
✅ Combination (merge, zip, combine_latest, with_latest_from)
✅ Error Handling (catch, retry, on_error_resume_next)
✅ Utility (do_action, delay, timestamp, observe_on)
✅ Time-based (sample, debounce, delay_subscription)
✅ Windowing & Buffering (buffer, window, group_by, all variants)
✅ Multicasting (share, publish, replay, multicast)
✅ Testing (all, some, is_empty, contains, sequence_equal)

Migration Guide

No migration needed! This is a pure feature addition. See docs/migration.rst for the new Migration v5 section with complete examples.

Breaking Changes

None - This release is 100% backward compatible. Minor Fix: Renamed internal ReplaySubject.window attribute to ReplaySubject._window to avoid naming conflict with the new window() method. This is a private implementation detail and should not affect user code.

@coveralls
Copy link

coveralls commented Nov 9, 2025

Coverage Status

coverage: 93.425% (-0.04%) from 93.462%
when pulling 27bb330 on fluent-style
into a999275 on master.

@dbrattli dbrattli changed the title [WIP] RxPY v5 RxPY v5 Nov 9, 2025
dbrattli and others added 4 commits November 10, 2025 19:00
Apply ruff formatting to all test files as Stage 0 of the test linting
enablement plan. This separates formatting changes from type annotation
work for cleaner diffs and easier review.

Changes:
- 19 files reformatted (mainly removing unnecessary line breaks)
- 167 files already formatted (no changes)
- All tests still pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace blanket "tests" exclusion with specific directory exclusions
matching the pyright configuration. This aligns both tools and makes
the staged rollout plan clearer.

Changes:
- Remove generic "tests" from ruff exclude list
- Add specific test directories to exclude
- Both ruff and pyright now have identical test exclusions
- Will remove exclusions incrementally as each stage completes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dbrattli dbrattli merged commit 05732f6 into master Nov 11, 2025
42 checks passed
@dbrattli dbrattli deleted the fluent-style branch November 11, 2025 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants