KEMBAR78
`stubgen --recursive` stubs entire package even when only subpackage was requested. · Issue #4844 · python/mypy · GitHub
Skip to content

stubgen --recursive stubs entire package even when only subpackage was requested. #4844

@mgilson

Description

@mgilson

This is a request for a slight change of behavior for stubgen. Right now, if I use stubgen --recursive urllib.parse, stubs will be generated for the entirety of urllib.

$ stubgen --recursive urllib.parse
Created out/urllib/__init__.pyi
Created out/urllib/error.pyi
Created out/urllib/parse.pyi
Created out/urllib/request.pyi
Created out/urllib/response.pyi
Created out/urllib/robotparser.pyi

This seems to be somewhat odd behavior -- I would have expected stubgen to only generate out/urllib/parse.pyi. To generate all the stubs, I would expect stubgen --recursive urllib (currently there is no difference between passing urllib.parse and urllib as the module to be stubbed).

The behavior is because of the use of __import__ rather than importlib.import_module in walk_packages.

I'm not completely sure if this is an intended feature or a bug, but I figured that I'd report it and find out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions