Skip to content

[stubgen] Add plugin support by passing a configuration file (#14428) #14436

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CarlosRDomin
Copy link

Fixes #14428

Similar to #9203, this PR exposes a way for stubgen to receive a Mypy configuration file with extra options, which allows it to use custom plugins.

if stubgen_options.mypy_config_file:

def set_strict_flags() -> None: # not needed yet
return
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure that this is correct. It would treat strict differently.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not too familiar with this callback so I had just replicated #9203
We can instead replicate main.py and do

    def set_strict_flags() -> None:
        for dest, value in strict_flag_assignments:
            setattr(options, dest, value)

would that work?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, something like this would work (I hope so, at least)!

Copy link
Author

Choose a reason for hiding this comment

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

I'm afraid I'm not familiar enough to know how to continue. The blurb I linked refers to a strict_flag_assignments variable that gets populated through some deeper method. Do you think strict flags are something that would be useful when parsing config files in stubgen.py? (I'm not sure of what strict flags even are, maybe with some extra context I can help implement something more robust)

Otherwise, would you be ok leaving the current implementation as is (it at least matches the existing [already merged] stubtest.py PR that inspired my PR) and someone more knowledgeable could propose a better handling of strict flags in the future?

Thanks for your quick response!

Copy link
Member

Choose a reason for hiding this comment

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

Ok, if this is hard to do, we can skip it for now :)

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Can you please add a test case similar to

def test_config_file(self) -> None:
?

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.

stubgen plugin support (via config file)
3 participants