Skip to content

output what class is subclassing rx.Base#5864

Merged
adhami3310 merged 1 commit intomainfrom
output-what-class-is-subclassing-rx.Base
Oct 9, 2025
Merged

output what class is subclassing rx.Base#5864
adhami3310 merged 1 commit intomainfrom
output-what-class-is-subclassing-rx.Base

Conversation

@adhami3310
Copy link
Member

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This PR improves the deprecation warning for `rx.Base` by adding the specific class name that is subclassing it. The change modifies line 33 in `reflex/base.py` to use f-string formatting with `{cls!r}` to display which exact class is triggering the deprecation warning.

The modification transforms a generic deprecation message into a more informative one that helps developers identify which specific classes in their codebase need to be migrated away from rx.Base. Instead of seeing a generic warning, developers will now see exactly which class is causing the deprecation, making it much easier to locate and update the problematic code.

This change fits well within Reflex's broader effort to deprecate rx.Base in favor of direct pydantic.BaseModel subclassing or dataclasses. The enhancement maintains the same deprecation behavior while providing better developer experience through more specific error reporting.

Important Files Changed

Changed Files
Filename Score Overview
reflex/base.py 5/5 Enhanced deprecation warning to include the specific class name subclassing rx.Base using f-string formatting

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only improves warning message clarity
  • Score reflects the simple nature of the change - it's purely a string formatting improvement with no functional impact
  • No files require special attention as this is a straightforward developer experience enhancement

Sequence Diagram

sequenceDiagram
    participant User
    participant "Custom Class" as CustomClass
    participant "rx.Base" as Base
    participant "console" as Console
    
    User->>CustomClass: "Define class inheriting from rx.Base"
    CustomClass->>Base: "__init_subclass__() called"
    Base->>Console: "console.deprecate() with class info"
    Console->>User: "Display deprecation warning with class name"
    Base->>Base: "super().__init_subclass__()"
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 9, 2025

CodSpeed Performance Report

Merging #5864 will not alter performance

Comparing output-what-class-is-subclassing-rx.Base (628aa7b) with main (f718715)

Summary

✅ 8 untouched

@adhami3310 adhami3310 merged commit 5fd8ea9 into main Oct 9, 2025
44 of 47 checks passed
@adhami3310 adhami3310 deleted the output-what-class-is-subclassing-rx.Base branch October 9, 2025 02:04
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