From c75345175e0f43920b06690782241901c1d177c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Sun, 14 Dec 2025 00:47:23 +0300 Subject: [PATCH 1/2] Upgrade to Python 3.14 --- .github/workflows/python-tests.yml | 2 +- .pre-commit-config.yaml | 8 ++++---- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 751831a3..21fa3fa6 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.13" + python-version: "3.14" cache: "pip" cache-dependency-path: requirements.*.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2076d158..960d02cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ --- default_language_version: - python: python3.13 + python: python3.14 repos: - repo: https://github.com/adamchainz/django-upgrade rev: 1.24.0 @@ -14,13 +14,13 @@ repos: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.7 + rev: v0.14.9 hooks: - id: ruff - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + rev: v3.21.2 hooks: - id: pyupgrade args: - - --py313-plus + - --py314-plus diff --git a/pyproject.toml b/pyproject.toml index 38eb606e..d5709551 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ python_files = [ extend-exclude = [ ".env", ] -target-version = "py313" +target-version = "py314" [tool.ruff.lint] extend-select = [ From a7f92efe9ab05d03055b518495e3dc06d2a822e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Sun, 14 Dec 2025 01:03:50 +0300 Subject: [PATCH 2/2] Apply pyupgrade fixes --- cbv/models.py | 24 ++++++++++++------------ cbv/queries.py | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cbv/models.py b/cbv/models.py index dddae0d3..c802df85 100644 --- a/cbv/models.py +++ b/cbv/models.py @@ -4,12 +4,12 @@ class ProjectVersionManager(models.Manager): - def get_by_natural_key(self, name: str, version_number: str) -> "ProjectVersion": + def get_by_natural_key(self, name: str, version_number: str) -> ProjectVersion: return self.get( version_number=version_number, ) - def get_latest(self) -> "ProjectVersion": + def get_latest(self) -> ProjectVersion: return self.order_by("-sortable_version_number")[0] @@ -52,7 +52,7 @@ def generate_sortable_version_number(self) -> str: class ModuleManager(models.Manager): def get_by_natural_key( self, module_name: str, project_name: str, version_number: str - ) -> "Module": + ) -> Module: return self.get( name=module_name, project_version=ProjectVersion.objects.get_by_natural_key( @@ -110,7 +110,7 @@ def get_absolute_url(self) -> str: class KlassManager(models.Manager): def get_by_natural_key( self, klass_name: str, module_name: str, project_name: str, version_number: str - ) -> "Klass": + ) -> Klass: return self.get( name=klass_name, module=Module.objects.get_by_natural_key( @@ -120,7 +120,7 @@ def get_by_natural_key( ), ) - def get_latest_for_name(self, klass_name: str) -> "Klass": + def get_latest_for_name(self, klass_name: str) -> Klass: qs = self.filter( name__iexact=klass_name, ) @@ -195,14 +195,14 @@ def get_source_url(self) -> str: line = self.line_number return f"{url}{version}{path}#L{line}" - def get_ancestors(self) -> models.QuerySet["Klass"]: + def get_ancestors(self) -> models.QuerySet[Klass]: if not hasattr(self, "_ancestors"): self._ancestors = Klass.objects.filter(inheritance__child=self).order_by( "inheritance__order" ) return self._ancestors - def get_children(self) -> models.QuerySet["Klass"]: + def get_children(self) -> models.QuerySet[Klass]: if not hasattr(self, "_descendants"): self._descendants = Klass.objects.filter( ancestor_relationships__parent=self @@ -211,7 +211,7 @@ def get_children(self) -> models.QuerySet["Klass"]: # TODO: This is all mucho inefficient. Perhaps we should use mptt for # get_all_ancestors, get_all_children, get_methods, & get_attributes? - def get_all_ancestors(self) -> list["Klass"]: + def get_all_ancestors(self) -> list[Klass]: if not hasattr(self, "_all_ancestors"): # Get immediate ancestors. ancestors = self.get_ancestors().select_related("module__project_version") @@ -233,7 +233,7 @@ def get_all_ancestors(self) -> list["Klass"]: self._all_ancestors = cleaned_ancestors return self._all_ancestors - def get_all_children(self) -> models.QuerySet["Klass"]: + def get_all_children(self) -> models.QuerySet[Klass]: if not hasattr(self, "_all_descendants"): children = self.get_children().select_related("module__project_version") for child in children: @@ -241,7 +241,7 @@ def get_all_children(self) -> models.QuerySet["Klass"]: self._all_descendants = children return self._all_descendants - def get_methods(self) -> models.QuerySet["Method"]: + def get_methods(self) -> models.QuerySet[Method]: if not hasattr(self, "_methods"): methods = self.method_set.all().select_related("klass") for ancestor in self.get_all_ancestors(): @@ -249,7 +249,7 @@ def get_methods(self) -> models.QuerySet["Method"]: self._methods = methods return self._methods - def get_attributes(self) -> models.QuerySet["KlassAttribute"]: + def get_attributes(self) -> models.QuerySet[KlassAttribute]: if not hasattr(self, "_attributes"): attrs = self.attribute_set.all() for ancestor in self.get_all_ancestors(): @@ -257,7 +257,7 @@ def get_attributes(self) -> models.QuerySet["KlassAttribute"]: self._attributes = attrs return self._attributes - def get_prepared_attributes(self) -> models.QuerySet["KlassAttribute"]: + def get_prepared_attributes(self) -> models.QuerySet[KlassAttribute]: attributes = self.get_attributes() # Make a dictionary of attributes based on name attribute_names: dict[str, list[KlassAttribute]] = {} diff --git a/cbv/queries.py b/cbv/queries.py index f36fb290..c17816a7 100644 --- a/cbv/queries.py +++ b/cbv/queries.py @@ -6,7 +6,7 @@ @attrs.frozen class VersionSwitcher: version_name: str - other_versions: list["OtherVersion"] + other_versions: list[OtherVersion] project_name: str = "Django" @attrs.frozen @@ -17,13 +17,13 @@ class OtherVersion: @attrs.frozen class NavData: - modules: list["Module"] + modules: list[Module] @attrs.frozen class Module: source_name: str short_name: str - classes: list["NavData.Klass"] + classes: list[NavData.Klass] active: bool @attrs.frozen @@ -39,7 +39,7 @@ def _to_module_data( module: models.Module, active_module: models.Module | None, active_klass: models.Klass | None, - ) -> "NavData.Module": + ) -> NavData.Module: return NavData.Module( source_name=module.source_name(), short_name=module.short_name(),