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

Resolve #304: Relax type requirement on pc.cond #323

Merged
merged 3 commits into from
Jan 24, 2023

Conversation

TommyDew42
Copy link
Contributor

Resolve #304: Relax type requirement on pc.cond

Comment on lines 25 to 29
cond_component = pc.cond(
cond_state.value,
pc.text("cond is True"),
pc.text("cond is False"),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pyright is complaining error: Module is not callable. Any thoughts?

Copy link
Contributor

@picklelo picklelo Jan 23, 2023

Choose a reason for hiding this comment

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

This may because we do some magic to create the pc. functions. In the tests maybe we can try to import the components directly:

from pynecone.components.typography.text import Text
from pynecone.components.layout.cond import Cond

Then call the create method explicitly:

cond_component = Cond.create(
    cond_state.value,
    Text.create("cond is True"),
    Text.create("cond is False"),
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. It seems to fix it.

This may because we do some magic to create the pc. functions.

I am curious how we do this? e.g. I don't see any def cond(): for pc.cond

Copy link
Contributor

@picklelo picklelo Jan 24, 2023

Choose a reason for hiding this comment

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

This is the line that does the magic: we create pc. functions that map to each component's create method.

@picklelo picklelo self-requested a review January 23, 2023 19:32
@picklelo picklelo modified the milestone: v0.1.14 Jan 23, 2023
@picklelo
Copy link
Contributor

Thanks for this change! If the fix doesn't work, we can also put a #type: ignore next to the offending lines

Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

Awesome

@picklelo picklelo merged commit f7e3577 into reflex-dev:main Jan 24, 2023
@TommyDew42 TommyDew42 deleted the relax-pc-cond.type-req branch January 25, 2023 15:47
ACucos1 pushed a commit to ACucos1/rd-pynecone that referenced this pull request Feb 28, 2023
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.

Relax type requirement on pc.cond
2 participants