Skip to content

Conversation

gentlegiantJGC
Copy link
Contributor

Types like union types have nested types in them.
The current implementation only removes the current module name from the root type name.
This modifies that behaviour so that it expands nested types recursively.
I discovered this through a mypy error that the module had not been imported.

Current behaviour

class Foo:
    pass

def test(arg: list[module.Foo] | module.Foo]) -> None: ...

Expected behaviour

class Foo:
    pass

def test(arg: list[Foo] | Foo]) -> None: ...

* Remove current module from nested types

Types like union types have nested types in them.
The current implementation only removes the current module name from the root type name.
This modifies that behaviour so that it expands nested types recursively.

* Add tests

* Reorder variant types

pybind11 requires that arguments are default constructable but Foo is not

* Reorder types in union

* Add nested types to all

* Add missing stubs
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.

1 participant