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

Any way to set param [Optional] ? #82

Open
ansvver opened this issue Dec 25, 2024 · 3 comments
Open

Any way to set param [Optional] ? #82

ansvver opened this issue Dec 25, 2024 · 3 comments

Comments

@ansvver
Copy link

ansvver commented Dec 25, 2024

I've tried to find out how to set "optional" param in _p2p.py but failed.

What I want is typing.Optional like

class B(BaseModel):
    c: str = Field(default="")

class A(BaseModel):
    b: typing.Optional[B] = Field()

thx a lot🎄🎄

@so1n
Copy link
Owner

so1n commented Dec 25, 2024

This is not currently supported, but I will try to support it

@ansvver
Copy link
Author

ansvver commented Dec 26, 2024

Great!!

Looks like it's not a simple job. Maybe the [default] value of the param will also be involved.

& thx again~

@ansvver
Copy link
Author

ansvver commented Dec 26, 2024

Not sure is there anyone need it, just put a quick fix script here:

sed -i 's/: \(.*\) = Field()/: typing.Optional[\1] = None/' my_p2p.py

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

No branches or pull requests

2 participants