Skip to content

Show subprocess.Popen instead of the defused wrapper in annotations - #896

Open
DSeaStar wants to merge 1 commit into
mitmproxy:mainfrom
DSeaStar:fix/defused-popen-annotation-name
Open

Show subprocess.Popen instead of the defused wrapper in annotations#896
DSeaStar wants to merge 1 commit into
mitmproxy:mainfrom
DSeaStar:fix/defused-popen-annotation-name

Conversation

@DSeaStar

Copy link
Copy Markdown

Fixes #819.

During import, pdoc replaces subprocess.Popen with _PdocDefusedPopen so modules cannot spawn unexpected processes. Evaluated annotations such as foo: subprocess.Popen[str] then stored the wrapper type, and formatannotation rendered it as pdoc.extract._PdocDefusedPopen.

Give the wrapper the same __name__ / __qualname__ / __module__ as subprocess.Popen so generated docs show the original type. The no-op behavior is unchanged.

Test plan

  • test_defused_popen_annotation_displays_as_subprocess_popen covers formatannotation and a module imported through load_module (class attribute + return annotation).

Import-time mocking replaced Popen with _PdocDefusedPopen, so evaluated
annotations leaked the internal class name into generated docs.
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.

subprocess.Popen is documented as pdoc.extract._PdocDefusedPopen

1 participant