Skip to content

Inline stubs from typeshed#96

Closed
MarcoGorelli wants to merge 2 commits intominrk:mainfrom
MarcoGorelli:inline-stubs
Closed

Inline stubs from typeshed#96
MarcoGorelli wants to merge 2 commits intominrk:mainfrom
MarcoGorelli:inline-stubs

Conversation

@MarcoGorelli
Copy link
Copy Markdown

closes #95

@MarcoGorelli MarcoGorelli marked this pull request as ready for review June 20, 2025 15:13
@@ -0,0 +1,187 @@
__all__ = [
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be in wurlitzer/init.pyi ? Otherwise it won't get installed and won't be usable by other projects, right?

And what do you think about inline type annotations vs these stub files?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review!

py.typed shouldn't be necessary if there's wurlitzer-stubs:

If the package is stub-only (not imported at runtime), the package should have a prefix of the runtime package name and a suffix of -stubs. A py.typed file is not needed for stub-only packages

https://mypy.readthedocs.io/en/stable/installed_packages.html

I've tried installing this from my branch in a virtual environment, and it finds the stubs fine:

(scratch) marcogorelli@DESKTOP-U8OKFP3:~/scratch$ uv pip uninstall wurlitzer
warning: Skipping wurlitzer as it is not installed
warning: No packages to uninstall
(scratch) marcogorelli@DESKTOP-U8OKFP3:~/scratch$ uv pip install git+https://github.com/MarcoGorelli/wurlitzer.git@inline-stubs --no-cache
    Updated https://github.com/MarcoGorelli/wurlitzer.git (cbe50b7f3b46aa6c2ce1d45e199f60da497b
Resolved 1 package in 2.74s
      Built wurlitzer @ git+https://github.com/MarcoGorelli/wurlitzer.git@cbe50b7f3b46aa6c2ce1d
Prepared 1 package in 1.03s
Installed 1 package in 2ms
 + wurlitzer==3.2.0.dev0 (from git+https://github.com/MarcoGorelli/wurlitzer.git@cbe50b7f3b46aa6c2ce1d45e199f60da497b5285)
(scratch) marcogorelli@DESKTOP-U8OKFP3:~/scratch$ cat t.py
from io import StringIO
import wurlitzer
from wurlitzer import Wurlitzer

reveal_type(Wurlitzer.flush_interval)

(scratch) marcogorelli@DESKTOP-U8OKFP3:~/scratch$ mypy t.py
t.py:5: note: Revealed type is "builtins.float"
Success: no issues found in 1 source file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what do you think about inline type annotations vs these stub files?

No preference to be honest

Happy to move the types into the Python file and have the py.typed if you prefer 👍

@MarcoGorelli MarcoGorelli marked this pull request as draft June 23, 2025 09:58
@MarcoGorelli MarcoGorelli marked this pull request as ready for review June 23, 2025 10:29
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.

Inline type stubs

2 participants