Skip to content

CI: Freeze DRF commit used in typecheck_tests and types-requests/types-urllib3 #345

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

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

@intgr intgr Feb 7, 2023

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.

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

django-stubs==1.13.0
django-stubs-ext==0.7.0
-e .[compatible-mypy,coreapi,markdown]
5 changes: 2 additions & 3 deletions scripts/git_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
from typing import Optional

from git import RemoteProgress, Repo
Expand All @@ -14,7 +13,7 @@ def update(self, op_code, cur_count, max_count=None, message=""):
print(self._cur_line)


def checkout_target_tag(drf_version: Optional[str]) -> Path:
def git_checkout_drf(commit_ref: Optional[str] = None) -> None:
if not DRF_SOURCE_DIRECTORY.exists():
DRF_SOURCE_DIRECTORY.mkdir(exist_ok=True, parents=False)
repository = Repo.clone_from(
Expand All @@ -27,4 +26,4 @@ def checkout_target_tag(drf_version: Optional[str]) -> Path:
else:
repository = Repo(DRF_SOURCE_DIRECTORY)
repository.remote("origin").pull("master", progress=ProgressPrinter(), depth=100)
repository.git.checkout(drf_version or "master")
repository.git.checkout(commit_ref or "master")
4 changes: 2 additions & 2 deletions scripts/stubgen-drf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from mypy.stubgen import generate_stubs, parse_options

from scripts.git_helpers import checkout_target_tag
from scripts.git_helpers import git_checkout_drf
from scripts.paths import DRF_SOURCE_DIRECTORY

if __name__ == "__main__":
Expand All @@ -12,6 +12,6 @@
args = parser.parse_args()
if DRF_SOURCE_DIRECTORY.exists():
shutil.rmtree(DRF_SOURCE_DIRECTORY)
checkout_target_tag(args.drf_version)
git_checkout_drf(args.drf_version)
stubgen_options = parse_options([f"{DRF_SOURCE_DIRECTORY}", "-o=stubgen"])
generate_stubs(stubgen_options)
8 changes: 6 additions & 2 deletions scripts/typecheck_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
from distutils import dir_util, spawn
from typing import Dict, List, Pattern, Union

from scripts.git_helpers import checkout_target_tag
from scripts.git_helpers import git_checkout_drf
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"
Copy link
Contributor

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


IGNORED_MODULES = []
MOCK_OBJECTS = [
"MockQueryset",
Expand Down Expand Up @@ -284,7 +288,7 @@ def update(self, op_code, cur_count, max_count=None, message=""):
parser = ArgumentParser()
parser.add_argument("--drf_version", required=False)
args = parser.parse_args()
checkout_target_tag(args.drf_version)
git_checkout_drf(args.drf_version or DRF_GIT_REF)
if sys.version_info[1] > 7:
shutil.copytree(STUBS_DIRECTORY, DRF_SOURCE_DIRECTORY / "rest_framework", dirs_exist_ok=True)
else:
Expand Down