Skip to content

[refactor] increase consistency in stdout and stderr optional arguments #19638

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wyattscarpenter
Copy link
Contributor

@wyattscarpenter wyattscarpenter commented Aug 10, 2025

I still think there's a good change to be had in here, but I'm trying a different approach. So, it stays as a draft PR for now.

On another note, sys.stdout and sys.strerr can themselves technically be None, and typeshed gives them MaybeNone to pay homage to this — I would like to actually handle this correctly in the mypy code here, but, what are you going to do, write a message to stderr about it? Guess we'll just roll on.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@wyattscarpenter
Copy link
Contributor Author

wyattscarpenter commented Aug 10, 2025

original comment, with the approach " [refactor] simply use default arguments for stdout and stderr"

Unless this runs me into the famous Python default argument folly, which doesn't seem likely to me, then this should be a better way to do it. (What, do we change sys.stdout during the course of the program? Guess CI will let me find out...) I guess you could argue that even trying to access a member variable like this sets us up for the footgun in the future...

Edit: "you could argue" — I've been convinced by my own argument. Also, I guess some of our test code, like a tiny amount, one test it seems, does actually rely on retargetting stderr or something.

@wyattscarpenter wyattscarpenter changed the title [refactor] simply use default arguments for stdout and stderr [refactor] increase consistency in stdout and stderr optional arguments Aug 11, 2025
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.

1 participant