You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That seems more reasonable - by all means propose a .pyi file with typing information, and I'll aim to keep that updated with any API changes. I'm not too familiar with Python typing tools - what would be a reasonable test that the typing information is complete for all APIs?
I dont think there is a way to test if the API is typed. All typing tools test the whole code of the project for missing types or type errors, to my knowledge there is no way to tell it "test only public API"
MonkeyType uses the sys.setprofile hook provided by Python to interpose on function calls, function returns, and generator yields, and record the types of arguments / return values / yield values.
So right not typeshed can't take the hints since this repo is not in module format? Or because they aren't up to their standard? If so I can try improve them?
And we don't want to change this repo to a module layout per #248 ?
I made a personal fork with type hints, in the module layout.
Added files
lovetox's hints gnupg/__init__.pyi
py.typed empty file gnupg/py.typed
GitHub action for using mypy to check type stubs
python3 -m mypy.stubtest gnupg
GitHub action to keep up to date from this repo
merges any new changes from vsajip/python-gnupg/master
moves gnupg.py to gnupg/__init__.py
modifies config.cfg so it builds, and with type hints
Don't actually use/trust my repo, i'm just a guy. Hinting works fine with my mypy/ty/pyright for my project that uses this module. https://github.com/kism/python-gnupg
Activity
vsajip commentedon Jan 14, 2025
I would prefer separate stubs, at least for now, as the package still supports Python 2.x.
vergenzt commentedon Jan 15, 2025
What if it were proposed in a separate
.pyifile, leaving the existing Python-2.x-compatible code unannotated?vsajip commentedon Jan 16, 2025
That seems more reasonable - by all means propose a
.pyifile with typing information, and I'll aim to keep that updated with any API changes. I'm not too familiar with Python typing tools - what would be a reasonable test that the typing information is complete for all APIs?lovetox commentedon Jan 28, 2025
https://github.com/microsoft/pyright/
and here a github action you can use https://github.com/jakebailey/pyright-action
lovetox commentedon Jan 28, 2025
#248
I dont think there is a way to test if the API is typed. All typing tools test the whole code of the project for missing types or type errors, to my knowledge there is no way to tell it "test only public API"
vergenzt commentedon Jan 28, 2025
@lovetox yeah pyright doesn't validate that type stubs are consistent with the base untyped Python code.
There's a mypy tool that targets this use case: Automatic stub testing (stubtest) - mypy 1.14.1 documentation
And more discussion here: python/mypy#5028
I've never attempted this though, so am not yet familiar with the rough edges.
vergenzt commentedon Jan 28, 2025
https://github.com/instagram/MonkeyType looks like a tool that might also be useful!
lovetox commentedon Feb 5, 2025
I contribute the stubs to typeshed, as after discussion the maintainer dont want to ship the stubs.
See python/typeshed#13465
kism commentedon Aug 15, 2025
So right not typeshed can't take the hints since this repo is not in module format? Or because they aren't up to their standard? If so I can try improve them?
And we don't want to change this repo to a module layout per #248 ?
I made a personal fork with type hints, in the module layout.
Added files
gnupg/__init__.pyignupg/py.typedpython3 -m mypy.stubtest gnupggnupg.pytognupg/__init__.pyDon't actually use/trust my repo, i'm just a guy. Hinting works fine with my mypy/ty/pyright for my project that uses this module.
https://github.com/kism/python-gnupg
hugovk commentedon Nov 10, 2026
I've opened another typeshed PR: python/typeshed#16757.
hugovk commentedon Nov 15, 2026
This is now merged and types-python-gnupg is now available 🚀
https://pypi.org/project/types-python-gnupg/
This issue can be closed.