Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-3943]type check for event handler if spec arg are typed #4046

Merged
merged 31 commits into from
Oct 31, 2024

Conversation

Lendemor
Copy link
Collaborator

@Lendemor Lendemor commented Oct 3, 2024

bonus: fix arg spec of slider.on_change

following snippet will now raise error:

class SliderState(rx.State):
    value: int = 50

    def set_end(self, value: int): # should be `list[int]` to pass the typecheck
        self.value = value # should be `value[0]`

@rx.page
def index():
    return rx.vstack(
        rx.heading(SliderState.value),
        rx.slider(
            default_value=40,
            on_change=SliderState.set_end,
        ),
        width="100%",
    )

@adhami3310
Copy link
Member

currently blocked on reflex-web to remove offending code

def check_fn_match_arg_spec(
fn: Callable,
arg_spec: ArgsSpec,
key: Optional[str] = None,
Copy link
Collaborator Author

@Lendemor Lendemor Oct 16, 2024

Choose a reason for hiding this comment

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

key is not used inside this particular method, should we remove the arg or did you mean to use it somewhere?

@ElijahAhianyo ElijahAhianyo changed the title type check for event handler if spec arg are typed [ENG-3943]type check for event handler if spec arg are typed Oct 21, 2024
Copy link

linear bot commented Oct 21, 2024

@adhami3310
Copy link
Member

blocked on reflex-dev/reflex-web#1042

reflex/components/el/elements/forms.py Outdated Show resolved Hide resolved
reflex/event.py Outdated Show resolved Hide resolved
@adhami3310 adhami3310 merged commit c07eb2a into main Oct 31, 2024
29 checks passed
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.

3 participants