Assign an alias to a type hint
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
Type hints such as defined by type_hint_identifier are automatically assigned to imports by PyO3, an extremely convenient feature. Unfortunately, there are rare cases where the type identifier can have the same name from multiple packages.
https://github.com/bufbuild/protovalidate-py/blob/871ad5faebc319b7b6c97259c0cb3f49da57f2c6/protovalidate/_protovalidate.pyi#L19
https://github.com/bufbuild/protovalidate-py/blob/871ad5faebc319b7b6c97259c0cb3f49da57f2c6/src/hints.rs#L37
I understand this is relatively niche but it would be great if we could add an alias to type_hint_identifier that is used in type annotations and added with as to the import.
Conflict handling reference:
There is a TODO to consider something like ModFoo. This may provide ProtobufMessage | Message for us which still wouldn't be much better than the number, so if going with a non-controlled approach without an explicit alias, it would be great if all members of a collision get transformed rather than one, in this case ProtobufMessage | GoogleProtobufMessage is reasonably clear.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/hints.rs and compare its type_hint_identifier handling with the conflict logic in pyo3-introspection/src/stubs.rs, including the referenced TODO. Trace how identifiers become imports and annotations. Done means an explicit alias can control both generated annotation names and imports, with a defined behavior for collisions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- developer-experience, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100