-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
CI: Freeze DRF commit used in typecheck_tests and types-requests/types-urllib3 #345
Conversation
Sigh! There are regressions from types-urllib3 and types-requests too! Scary how fragile Python typing still is.
EDIT: Reported to upstream: python/typeshed#9690 |
@@ -5,6 +5,8 @@ pytest==7.2.1 | |||
pytest-mypy-plugins==1.10.1 | |||
djangorestframework==3.14.0 | |||
types-pytz==2022.7.1.0 | |||
types-requests==2.28.11.8 | |||
types-urllib3==1.26.25.4 |
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.
Latest types-requests and types-urllib3 are already incompatible with mypy 0.991.
I think it's a good idea to keep these pinned in any case. Dependabot will keep them up to date.
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.
Definitely a good idea to pin those dependencies in general
@mschoettle Any thoughts on this? |
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.
I don't have perms to meaningfully approve this, but I agree that this is a problem and your patch looks like a great solution. ✅
from scripts.paths import DRF_SOURCE_DIRECTORY, PROJECT_DIRECTORY, STUBS_DIRECTORY | ||
|
||
# django-rest-framework commit hash to check against (ignored with --drf_version) | ||
# This should be updated periodically or after every DRF release. | ||
DRF_GIT_REF = "22d206c1e0dbc03840c4d190f7eda537c0f2010a" |
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.
LGTM, this is 1 week old: encode/django-rest-framework@22d206c
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.
@mschoettle Any thoughts on this?
Thanks for asking!
To be honest, I am not too familiar with the whole typeshed stuff and the purpose of the typecheck_tests script. I am generally fine with it but a bit wary with these kind of manual changes that are then required. I'll give you my general thoughts/questions:
If the commit is pinned, would this prevent these kind of errors to ever show up?
Ideally, they would appear somewhere on here. I assume they would now surface in the dependabot PR to update the third-party types (now that they are pinned), right?
If that is the case, would that solve the problem without having to pin the commit?
Another thing I am wondering: Can a new PR introduce changes that cause type errors that would not be found because another commit is checked against?
Hope it's helpful and the questions are based on my limited understanding of how it is setup :)
@@ -5,6 +5,8 @@ pytest==7.2.1 | |||
pytest-mypy-plugins==1.10.1 | |||
djangorestframework==3.14.0 | |||
types-pytz==2022.7.1.0 | |||
types-requests==2.28.11.8 | |||
types-urllib3==1.26.25.4 |
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.
Definitely a good idea to pin those dependencies in general
Ah, for background: typecheck_tests.py runs in CI. It makes a git checkout of the django-rest-framework (DRF) project and then runs mypy over its test suite together with our stubs. The idea is that DRF test suite provides some example code that we can verify our type stubs against. Since upstream's test suite doesn't have proper type hints, there are bound to be lots of false positives where mypy's inference doesn't guess the intent of the developer, or hacks were made for testing purposes. So we have a massive Since we took the latest |
There are two changes in this PR. One is pinning types-requests and types-urllib3, that's just incidental, because those packages just now happened to break compatibility with mypy 0.991 and would break our CI. Dependabot will update them and they aren't a concern. The significant part is is freezing the git hash in typecheck_tests.py. I doubt we can make Dependabot update this. |
I think you're right, but we can build a simple GitHub Action that runs ~weekly to update this and open a PR, similar to Dependabot. Very happy to help with this if it's a high priority, and we could reuse it in django-stubs. |
That would be helpful, though I wouldn't say it's high priority. In the longer term I'd hope to see mypy_primer integrated, which handles false positives far better because it only reports diffs between mypy results (before and after PR changes). With that, I would suggest dropping typecheck_tests entirely, so we can get rid of the burden of maintaining these ignores. I've opened an issue at typeddjango/django-stubs#1362 to discuss that. |
Thanks for the additional background, @intgr! And apologies. I misread the code in the I am wondering if the pinned DRF version in |
Thanks for the reviews! |
FYI @christianbundy.
As discussed in #339 (comment), using the latest master branch state in typecheck_tests frequently causes CI failures to pop up in unrelated pull requests.