stubgen & pybind11: can we make them play nice(r)?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
We're experimenting under https://github.com/pybind/pybind11/pull/4888 with a pybind11 behavior change, to generate
Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]
instead of a bare cpp_namespace::UserType.
It seems like mypy does handle outer-level Annotated, but not nested ones, e.g.
Iterator[str, Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]]
The results from stubgen (1.5.1, Google-internal toolchain) are like this:
def values(self, *args, **kwargs) -> Any: ...
Desired is:
def values(self) -> Iterator[str, Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]]: ...
Does this ring any bells?
If you need more details, please let me know. (Note though that I don't know a lot about typing and mypy. This fell into my lap as Google-internal pybind11 owner & pybind11 maintainer on github.)
A more general question: What are your thought about changing the pybind11 behavior in this way? Is there a better way?
(A clear and concise description of what the bug is.)
To Reproduce
# Ideally, a small sample program that demonstrates the problem.
# Or even better, a reproducible playground link https://mypy-play.net/ (use the "Gist" button)
Expected Behavior
Actual Behavior
Your Environment
- Mypy version used: 1.5.1, Google-internal toolchain
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.10
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Der Bericht nennt stubgen und zeigt ein verschachteltes Annotated-Beispiel, enthält aber keine Repository-Dateien oder Tests. Beginne damit, das Verhalten mit dem gezeigten Python-3.10-Beispiel und stubgen 1.5.1 zu reproduzieren, und verfolge dann, an welcher Stelle die Signatur zu *args, **kwargs wird. Die Aufgabe ist abgeschlossen, wenn die generierte Ausgabe die verschachtelten Iterator- und Annotated-Typen wie in der gewünschten Signatur beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100