-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix 'WriteToConn' object has no attribute 'flush'
#16801
Conversation
This default isn't used anywhere in the codebase.
7229960
to
3241a72
Compare
This comment has been minimized.
This comment has been minimized.
3241a72
to
aee0c2a
Compare
This class replaced stdout and stderr to capture output, but caused issues because it didn't implement the full API of sys.stdout and sys.stderr. By fully stubbing the TextIO API we prevent issues with other code which uses more of the API than we had previously accounted for. Fixes python#16678
b939bb3
to
a405475
Compare
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Thanks for the fix! |
Is there any chance this could make it into a 1.7.2 release? Or is 1.7 not really maintained any more? |
@mattwedge Generally mypy doesn't backport bugfixes. Is there a reason you can't upgrade to a release that includes this fix (1.9+)? |
It's for a Django project which uses django-stubs which as you can see at https://pypi.org/project/django-stubs/ requires that we use mypy 1.7.x for Django 4. It seems that in order to use the latest mypy we would have to upgrade to Django 5 |
You may have luck trying version combinations outside of the ones in that table. The latest version of that table now has this text below it, which gives some insight:
From skimming the linked discussion comment, it seems that the latest versions of django-stubs are still mostly compatible with Django 4, and should work fine with a range of mypy versions. The reason django-stubs relies on particular versions of mypy is to guard against plugin API changes. From what I can tell, there were no plugin API changes between v1.4 and v1.11, so all versions from within that range should be equally compatible. (there was one plugin API change in v1.12, which would require using django-stubs v5.1.1 or later). |
WriteToConn
replaces stdout and stderr to capture output, but causes issues because it doesn't implement theTextIO
API (as expected ofsys.stdout
andsys.stderr
).By stubbing the rest of the
TextIO
API we prevent issues with other code which uses more of the API than we had previously accounted for.Fixes #16678