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

Convert example parameter into examples on Field #122

Merged
merged 3 commits into from
Sep 18, 2023

Conversation

Gamrix
Copy link
Contributor

@Gamrix Gamrix commented Aug 21, 2023

This codemod is intended to convert an example to a single element list of examples.

When I tried to run it however, I get the following exception from libcst. I presume it is because there is a bug with the list construct, but it could be a coding mistake on my part.

Thanks Brian for the suggestion that fixed this PR.

self = Integer(
    value='1',
    lpar=[],
    rpar=[],
)
state = CodegenState(default_indent='    ', default_newline='\n', provider=None, indent_tokens=['    '], tokens=['from', ' ', ...'int', ' ', '=', ' ', 'Field', '', '(', '', '', '', '...', '', ',', ' ', '', '', '', 'examples', '', '=', '', '[', ''])
kwargs = {'default_comma': False, 'default_comma_whitespace': True}

    def _codegen(self, state: CodegenState, **kwargs: Any) -> None:
        state.before_codegen(self)
>       self._codegen_impl(state, **kwargs)
E       TypeError: _codegen_impl() got an unexpected keyword argument 'default_comma'

../../.pyenv/versions/3.9.16/lib/python3.9/site-packages/libcst/_nodes/base.py:300: TypeError
- generated xml file: /var/folders/sh/fdr554614wlb2s12tx1bw8wm0000gn/T/tmp-78979sbVUwmyuq3zy.xml -

EDIT by @Kludex:

@Gamrix Gamrix changed the title Tried to add Codemod for Examples conversion Codemod for Examples conversion Sep 12, 2023
@Kludex Kludex changed the title Codemod for Examples conversion Convert example parameter into examples on Field Sep 18, 2023
@Kludex Kludex merged commit e0a6ba9 into pydantic:main Sep 18, 2023
7 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.

Field(example=...) needs a codemod.
3 participants