Skip to content

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

Open
@tbuzzelli

Description

@tbuzzelli

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]: ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @tbuzzelli@AlexWaygood

      Issue actions

        strip_or_import no longer fixes types of the form "module.foo[str,str]" · Issue #16138 · python/mypy