-
Notifications
You must be signed in to change notification settings - Fork 148
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 Mypy linting with latest Twisted #239
Conversation
Signed-off-by: H.Shay <shaysquared@gmail.com>
It might be worth trying to fix up the type hints like we did for Synapse: matrix-org/synapse#10490, or does newer Twisted versions actually not pass other tests for some reason? |
Twisted adding type hints, which caused the mypy CI check to fail is what precipitated was this PR, as you mentioned. Oliver had just suggested that pinning/constraining the version in general was probably the proper thing to do to avoid similar problems in the future. So pinning the version wasn't necessarily to avoid fixing the type hints, it was just to prevent CI from breaking unexpectedly in future. |
pinning a library to a particular version is oookayyy but, to my mind, brings with it a commitment to regularly review the latest changes and upgrade, to avoid getting stuck on an old version. (In general, it's much easier to keep on top of library changes with regular small updates than by doing one big update after months or years.) I don't think we're in a position to make that commitment here. In the particular case of Twisted, it's worth noting that they have a very strong compatibility policy in which they essentially promise not to break runtime compatibility - but they also don't provide any security support for anything but the latest version. It's unfortunate that the changes in Twisted 21.7 means that we require extra type hints, but that's very much an unusual case - and even then, it only breaks All that is a long-winded way of saying: I think pinning the version is okay as a temporary measure to make CI green again, but I don't think we should pin Twisted in the long term. |
I took away the version constraint -- my mistake for suggesting it (I must have dreamt that we did it). There are just 3 mypy issues -- just applying the small changes you had in the other PR should make everything happy again (and I suppose change the newsfile and remove the 237 newsfile), then this PR should be a good'un :) |
Sounds like we should let the target version in setup.py float, but use something like Poetry, Pipenv, or pip-tools to pin the specific versions we rely on so that our CI and releases are more deterministic. We can turn on Dependabot to ensure that everything is kept up to date and tested with more recent versions, without needing as much of a commitment on our end. ...but this is a tangent and I'll politely return to figuring out where to best propose this :) |
Signed-off-by: Dan Callahan <danc@element.io>
We've dropped Buildkite and switched up GHA to run on all pull requests in #240, so I've taken the liberty of merging main, removing the extraneous changelog file, and pushing to Shay's branch. |
Signed-off-by: Dan Callahan <danc@element.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
...and in the interest of getting CI green, I went ahead and fixed the errors 😆 |
I think that this will now break with old versions of Twisted, which is why we quoted all of the types in the Synapse PR. |
@clokep Tests appear to pass locally with 19.7.0, and we do exercise the I could throw in a |
@richvdh and I had a conversation about it in #synapse-dev:matrix.org: https://matrix.to/#/!XaqDhxuTIlvldquJaV:matrix.org/$mpaHhwF-RQLR4TscGgrUHwX9W3lAGcBQMysydMSrOUw?via=matrix.org&via=vector.modular.im&via=envs.net
Unfortunately it seems like the past CI run is gone, so I can't see exactly what failed. I can't say anything looks dramatically different between the Synapse and Sygnal PRs with the way we're using Deferreds.
Well I'd prefer we keep things consistent and solve it the same way for our different packages. |
For the record, if I run https://github.com/matrix-org/synapse/tree/rav/broken_deferred_annotations in a virtualenv with Twisted 21.2 (and python 3.8) I get:
That error is on this line: https://github.com/matrix-org/synapse/blob/rav/broken_deferred_annotations/synapse/util/async_helpers.py#L476. |
I did some testing. First of all, Twisted 19.2.1 fails because of missing things that we use in the test suite. Upgraded to Twisted 19.7. It's fine with |
This PR sets a constraint for the Twisted version to avoid upstream version changes breaking CI, and fixes a few type errors introduced by an upstream Twisted version update.