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

pydantic.errors.PydanticUserError: MenuEntry is not fully defined; you should define BuilderContext, then call MenuEntry.model_rebuild(). #226

Open
liyown opened this issue Nov 28, 2024 · 2 comments · May be fixed by #227

Comments

@liyown
Copy link

liyown commented Nov 28, 2024

python 3.10

@liyown
Copy link
Author

liyown commented Nov 28, 2024

to resolve:

class MenuEntry(BaseModel):
    code: str
    cli_name: Optional[str] = None
    user_view: str
    description: str
    is_hidden: Optional[Callable[["BuilderContext"], bool]] = None
    additional_info: Optional[Any] = None

    @property
    def generated_name(self) -> str:
        """
        Property to generate parameter name.

        It checks if cli_name is present,
        otherwise, code is used.

        :return: string to use in CLI.
        """
        if self.cli_name:
            return self.cli_name
        return self.code

class BuilderContext(BaseModel):
    pass

MenuEntry.model_rebuild()

SKIP_ENTRY = MenuEntry(
    code="skip",
    user_view="skip",
    description="skip",
)

@s3rius
Copy link
Owner

s3rius commented Dec 14, 2024

This one seems a bad bug. It will be fixed during the next dependency update.

@s3rius s3rius linked a pull request Dec 26, 2024 that will close this issue
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 a pull request may close this issue.

2 participants