Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add executable kwarg to trio.run_process type hints #3183

Open
dj-foxxy opened this issue Jan 12, 2025 · 4 comments
Open

Add executable kwarg to trio.run_process type hints #3183

dj-foxxy opened this issue Jan 12, 2025 · 4 comments
Labels
good first issue typing Adding static types to trio's interface

Comments

@dj-foxxy
Copy link

The executable kwarg is missing from the type hints of trio.run_process. It works at run time but Pyright is complaining.

@clivinn-shla81092
Copy link

Hello, we tried to solve the issue.

This is what we did:

Add the 'executable' parameter to the type hints for the run_process function in both Windows and Unix overloads. This will resolve the Pyright complaint about the missing 'executable' kwarg.

You can review changes in this commit: clivinn-shla81092@a83f9d7.

Caution

Disclaimer: The concept of solution was created by AI and you should never copy paste this code before you check the correctness of generated code. Solution might not be complete, you should use this code as an inspiration only.


Latta AI seeks to solve problems in open source projects as part of its mission to support developers around the world. Learn more about our mission at https://latta.ai/ourmission . If you no longer want Latta AI to attempt solving issues on your repository, you can block this account.

@A5rocks
Copy link
Contributor

A5rocks commented Jan 12, 2025

The executable kwarg is missing from the type hints of trio.run_process. It works at run time but Pyright is complaining.

Absolutely, and it looks like we're missing other kwargs in the signature too. (and same for trio.open_process) Namely:

  • executable (of course)
  • group (3.9+, unix)
  • extra_groups (3.9+, unix)
  • user (3.9+, unix)
  • umask (3.9+, unix)
  • pipesize (3.10+, linux but is ignored so all platforms? or maybe unix)
  • process_group (3.11+, unix)

Feel free to make a PR -- you'll have to add some if sys.version_info checks and update the cheat sheet comment on top of the overloads.


If you no longer want Latta AI to attempt solving issues on your repository, you can block this account.

Done!

@A5rocks A5rocks added good first issue typing Adding static types to trio's interface labels Jan 12, 2025
@jakkdl
Copy link
Member

jakkdl commented Jan 12, 2025

That if TYPE_CHECKING block is gonna become an absolute monstrosity - it's already a ~third of the file with 400 lines. This might warrant a separate file (_subprocess_type_hints.py?) and maybe also a dedicated test that compares the type-checker inferred signature with that of subprocess.run (although given the false alarm rate on test_static_tool_sees_[...] I'm not terribly excited about that)

@A5rocks
Copy link
Contributor

A5rocks commented Jan 12, 2025

maybe also a dedicated test that compares the type-checker inferred signature with that of subprocess.run (although given the false alarm rate on test_static_tool_sees_[...] I'm not terribly excited about that)

I don't think this is possible because typeshed structures its overloads differently to ours (eg no platform specific ones)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue typing Adding static types to trio's interface
Projects
None yet
Development

No branches or pull requests

4 participants