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

strip_or_import no longer fixes types of the form "module.foo[str,str]" #16138

Open
tbuzzelli opened this issue Sep 18, 2023 · 0 comments · May be fixed by #16139
Open

strip_or_import no longer fixes types of the form "module.foo[str,str]" #16138

tbuzzelli opened this issue Sep 18, 2023 · 0 comments · May be fixed by #16139
Labels
bug mypy got something wrong topic-stubgen

Comments

@tbuzzelli
Copy link

Bug Report

Stubgenc's strip_or_import no longer fixes types that contain a [.

This seems to be caused by #14564

Specifically, [ is not included in the match for the regex replacement. This causes the subtype before the [ to not be replaced as it should be.

To Reproduce

Create a py extension with a function which has a return type referencing a class in the local module with [ in the type.

Expected Behavior

The fully-qualified module should be excluded.

class KeysView[str]:
    ...

class MyMap:
    def keys(self) -> KeysView[str]: ...

Actual Behavior

The fully-qualified name is left behind and not replaced.

class KeysView[str]:
    ...

class MyMap:
    def keys(self) -> full.module.name.KeysView[str]: ...
@tbuzzelli tbuzzelli added the bug mypy got something wrong label Sep 18, 2023
@tbuzzelli tbuzzelli linked a pull request Sep 18, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-stubgen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants