Skip to content

Add type annotation to Parameter.rx property#1112

Open
Copilot wants to merge 6 commits intomainfrom
copilot/type-annotate-parameter-rx
Open

Add type annotation to Parameter.rx property#1112
Copilot wants to merge 6 commits intomainfrom
copilot/type-annotate-parameter-rx

Conversation

Copy link

Copilot AI commented Feb 9, 2026

The Parameter.rx property was not type annotated, preventing IDEs from providing autocomplete and type information for reactive expressions.

import param

class P(param.Parameterized):
    a = param.Number()

p = P(a=1)
rx_expression = p.param.a.rx()  # IDE cannot infer type

Changes

  • Added -> 'rx' return type annotation to Parameter.rx property
  • Imported rx under TYPE_CHECKING guard to avoid circular import with reactive module

With this change, IDEs will correctly identify p.param.a.rx as rx, enabling autocomplete for reactive operations like .pipe(), .map(), .and_(), etc., matching the type expectations of basedpyright and other type checkers.

Original prompt

This section details on the original issue you should resolve

<issue_title>Type annotate Parameter.rx property</issue_title>
<issue_description>VS Code and other editors relying on static typing does not understand what rx_expression below is because Parameter.rx property is not type annotated:

import param
class P(param.Parameterized):
    a = param.Number()
p = P(a=1)
rx_expression = p.param.a.rx()

This is a huge bummer on developer experience as you don't get any help from there.

Please type annotate it. It probably requires some reordering of the code to avoid circular imports.</issue_description>

<agent_instructions>Please start out by understanding the problem very well. Then plan how to solve it. Then solve it. Include relevant pytests. Make sure all existing tests and pre-commit tests succeed. Keep the change as simple if possible. Making it easy to review.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 9, 2026 13:05
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Copilot AI changed the title [WIP] Add type annotation to Parameter.rx property Add type annotation to Parameter.rx property Feb 9, 2026
Copilot AI requested a review from MarcSkovMadsen February 9, 2026 13:09
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.22%. Comparing base (833c8f0) to head (f85eef5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1112   +/-   ##
=======================================
  Coverage   89.22%   89.22%           
=======================================
  Files           9        9           
  Lines        4716     4716           
=======================================
  Hits         4208     4208           
  Misses        508      508           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen left a comment

Choose a reason for hiding this comment

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

Probably works for me

Image

I'm in doubt whether rx is the correct type annotation. But its the one basedpyright suggests and wants.

Image

Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen left a comment

Choose a reason for hiding this comment

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

studying reactive_ops I can see it actually returns rx class defined in reactive.py. Please update the type annotation. Fix any failing pytest or pre-commit tests.

Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 9, 2026

studying reactive_ops I can see it actually returns rx class defined in reactive.py. Please update the type annotation. Fix any failing pytest or pre-commit tests.

Updated type annotation from reactive_ops to rx in commit f85eef5. All tests and pre-commit checks pass.

Copilot AI requested a review from MarcSkovMadsen February 9, 2026 14:43
@MarcSkovMadsen MarcSkovMadsen marked this pull request as ready for review February 9, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type annotate Parameter.rx property

2 participants