From e0604a41d359c8c29e539b69e8894f62520f8768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Thu, 21 Apr 2022 11:22:34 -0300 Subject: [PATCH 1/6] Add the possibility to set a max version - remove new line character from version and compat_version before generate the markdown --- scripts/create_django_issue.py | 48 +++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/scripts/create_django_issue.py b/scripts/create_django_issue.py index daee8fe16..f1ff51a06 100644 --- a/scripts/create_django_issue.py +++ b/scripts/create_django_issue.py @@ -47,6 +47,11 @@ class DjVersion(NamedTuple): major, minor, *_ = version_str.split(".") return cls(major=int(major), minor=int(minor)) + @classmethod + def parse_to_tuple(cls, version_str: str): + version = cls.parse(version_str=version_str) + return version.major, version.minor + def get_package_info(package: str) -> dict: """Get package metadata using PyPI API.""" @@ -75,17 +80,22 @@ def get_name_and_version(requirements_line: str) -> tuple[str, ...]: return name_without_extras, version -def get_all_latest_django_versions() -> tuple[DjVersion, list[DjVersion]]: +def get_all_latest_django_versions( + django_max_version: tuple[DjVersion] = None, +) -> tuple[DjVersion, list[DjVersion]]: """ Grabs all Django versions that are worthy of a GitHub issue. - Depends on Django versions having higher major version or minor version. """ + _django_max_version = (99, 99) + if django_max_version: + _django_max_version = django_max_version + print("Fetching all Django versions from PyPI") base_txt = REQUIREMENTS_DIR / "base.txt" with base_txt.open() as f: for line in f.readlines(): - if "django==" in line: + if "django==" in line.lower(): break else: print(f"django not found in {base_txt}") # Huh...? @@ -97,7 +107,7 @@ def get_all_latest_django_versions() -> tuple[DjVersion, list[DjVersion]]: current_minor_version = DjVersion.parse(current_version_str) newer_versions: set[DjVersion] = set() for django_version in get_django_versions(): - if django_version > current_minor_version: + if _django_max_version >= django_version >= current_minor_version: newer_versions.add(django_version) return current_minor_version, sorted(newer_versions, reverse=True) @@ -143,7 +153,13 @@ class GitHubManager: for requirements_file in self.requirements_files: with (REQUIREMENTS_DIR / f"{requirements_file}.txt").open() as f: for line in f.readlines(): - if "==" in line and not line.startswith("{%"): + if ( + "==" in line + and not line.startswith("{%") + and not line.startswith(" #") + and not line.startswith("#") + and not line.startswith(" ") + ): name, version = get_name_and_version(line) self.requirements[requirements_file][name] = ( version, @@ -192,9 +208,9 @@ class GitHubManager: # updated packages, or known releases that will happen but haven't yet if issue := self.existing_issues.get(needed_dj_version): if index := issue.body.find(package_name): - name, _current, prev_compat, ok = [ + name, _current, prev_compat, ok = ( s.strip() for s in issue.body[index:].split("|", 4)[:4] - ] + ) if ok in ("✅", "❓", "🕒"): return prev_compat, ok @@ -251,11 +267,12 @@ class GitHubManager: ) requirements += ( f"| {self._get_md_home_page_url(info).format(package_name)} " - f"| {version} " - f"| {compat_version} " + f"| {version.strip()} " + f"| {compat_version.strip()} " f"| {icon} " f"|\n" ) + return requirements def create_or_edit_issue(self, needed_dj_version: DjVersion, description: str): @@ -277,9 +294,11 @@ class GitHubManager: self.create_or_edit_issue(version, md_content) -def main() -> None: +def main(django_max_version=None) -> None: # Check if there are any djs - current_dj, latest_djs = get_all_latest_django_versions() + current_dj, latest_djs = get_all_latest_django_versions( + django_max_version=django_max_version + ) if not latest_djs: sys.exit(0) manager = GitHubManager(current_dj, latest_djs) @@ -292,4 +311,9 @@ if __name__ == "__main__": raise RuntimeError( "No github repo, please set the environment variable GITHUB_REPOSITORY" ) - main() + max_version = None + last_arg = sys.argv[-1] + if CURRENT_FILE.name not in last_arg: + max_version = DjVersion.parse_to_tuple(version_str=last_arg) + + main(django_max_version=max_version) From 865e97136cc0d9d4b1fa81b3b0f6d78947e6c2f0 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Wed, 27 Apr 2022 01:44:00 -0700 Subject: [PATCH 2/6] Update drf-spectacular from 0.22.0 to 0.22.1 (#3684) --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 827362ae1..ac6b637eb 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -44,5 +44,5 @@ django-redis==5.2.0 # https://github.com/jazzband/django-redis djangorestframework==3.13.1 # https://github.com/encode/django-rest-framework django-cors-headers==3.11.0 # https://github.com/adamchainz/django-cors-headers # DRF-spectacular for api documentation -drf-spectacular==0.22.0 # https://github.com/tfranzel/drf-spectacular +drf-spectacular==0.22.1 # https://github.com/tfranzel/drf-spectacular {%- endif %} From b051b41129dd2dca6e4c69c37595e397d3237b63 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Wed, 27 Apr 2022 13:06:33 -0700 Subject: [PATCH 3/6] Update python-slugify to 6.1.2 (#3686) --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index ac6b637eb..f0753f572 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1,5 +1,5 @@ pytz==2022.1 # https://github.com/stub42/pytz -python-slugify==6.1.1 # https://github.com/un33k/python-slugify +python-slugify==6.1.2 # https://github.com/un33k/python-slugify Pillow==9.1.0 # https://github.com/python-pillow/Pillow {%- if cookiecutter.frontend_pipeline == 'Django Compressor' %} {%- if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} From 0ff679073b58368fe3de6263af1a828fe635b05a Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Wed, 27 Apr 2022 13:08:23 -0700 Subject: [PATCH 4/6] Update mypy to 0.950 (#3687) --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 7944f35c1..ea65e429c 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -13,7 +13,7 @@ watchgod==0.8.2 # https://github.com/samuelcolvin/watchgod # Testing # ------------------------------------------------------------------------------ -mypy==0.942 # https://github.com/python/mypy +mypy==0.950 # https://github.com/python/mypy django-stubs==1.9.0 # https://github.com/typeddjango/django-stubs pytest==7.1.2 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.4 # https://github.com/Frozenball/pytest-sugar From 870ed7eaf80e818a663f0abc37ced9e170297f43 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 28 Apr 2022 02:59:24 +0000 Subject: [PATCH 5/6] Release 2022.04.27 --- CHANGELOG.md | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac9bf7d86..a616f9469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All enhancements and patches to Cookiecutter Django will be documented in this f +## 2022.04.27 + +### Updated +- Update mypy to 0.950 ([#3687](https://github.com/cookiecutter/cookiecutter-django/pull/3687)) +- Update python-slugify to 6.1.2 ([#3686](https://github.com/cookiecutter/cookiecutter-django/pull/3686)) +- Update drf-spectacular to 0.22.1 ([#3684](https://github.com/cookiecutter/cookiecutter-django/pull/3684)) + ## 2022.04.25 ### Updated diff --git a/setup.py b/setup.py index ad69562b3..3b3bf6b2f 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: from distutils.core import setup # We use calendar versioning -version = "2022.04.25" +version = "2022.04.27" with open("README.rst") as readme_file: long_description = readme_file.read() From 3d7a2db072873496bd4cc779f9a2331bd46da81b Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 29 Apr 2022 02:46:26 +0000 Subject: [PATCH 6/6] Release 2022.04.28 --- CHANGELOG.md | 5 +++++ setup.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a616f9469..2ad4c77d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All enhancements and patches to Cookiecutter Django will be documented in this f +## 2022.04.28 + +### Changed +- Add the possibility to set a max django version on create_django_issue script ([#3680](https://github.com/cookiecutter/cookiecutter-django/pull/3680)) + ## 2022.04.27 ### Updated diff --git a/setup.py b/setup.py index 3b3bf6b2f..eb5db1a03 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: from distutils.core import setup # We use calendar versioning -version = "2022.04.27" +version = "2022.04.28" with open("README.rst") as readme_file: long_description = readme_file.read()