Skip to content

Commit

Permalink
feat: python 3.12 (#244)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Upgraded Python version to 3.12.6, potentially introducing new
features and optimizations.
- Updated several dependencies, including `django-configurations` to
version 2.4.2, `django-webpack-loader` to version 3.1.1, and
`django-debug-toolbar` to version 4.4.6 for improved functionality and
performance.
- **Bug Fixes**
- Downgraded `django-allauth` to version 0.54.0 to maintain
compatibility and stability in authentication features.
- Updated base images in Dockerfile to leverage enhancements from newer
Python versions.
- **Chores**
- Updated pre-commit hook versions for improved linting and formatting
capabilities.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
thejoeejoee authored Sep 18, 2024
2 parents 231e368 + 3b99851 commit 8c97d9c
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 268 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
repos:
# basic hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -23,37 +23,37 @@ repos:
- id: detect-private-key

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [ "--profile", "black", "--filter-files" ]

# security linter on
- repo: https://github.com/pycqa/bandit
rev: 1.7.5
rev: 1.7.9
hooks:
- id: bandit
name: check security by Bandit
args: [ '-iii', '-ll' ]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.1.6'
rev: 'v0.6.5'
hooks:
- id: ruff
name: lint by Ruff
args: [ --fix, --exit-non-zero-on-fix ]

# uncompromise python formatter
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.8.0
hooks:
- id: black
name: format by black
exclude: ^.*\b(migrations)\b.*$

- repo: https://github.com/Riverside-Healthcare/djlint
rev: 'v1.34.0' # replace with the latest tag on GitHub
rev: 'v1.35.2' # replace with the latest tag on GitHub
hooks:
- id: djlint-django
entry: djlint --reformat
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ARG DJANGO_RELEASE_NAME
ARG SENTRY_RELEASE_NAME
ARG SENTRY_RELEASE_ENVIRONMENT

ARG PYTHON_IMAGE=python:3.12.6-alpine3.20

#
# wiki renderer image
#
Expand Down Expand Up @@ -91,7 +93,7 @@ RUN \
#

# venv builder
FROM python:3.11.3-alpine3.17 as web-venv-builder
FROM ${PYTHON_IMAGE} as web-venv-builder

ARG POETRY_EXPORT_ARGS

Expand All @@ -113,7 +115,7 @@ RUN poetry export --without-hashes ${POETRY_EXPORT_ARGS} -o /tmp/requirements.tx
RUN --mount=type=cache,target=/root/.cache/pip /venv/bin/pip install -r /tmp/requirements.txt

# base runtime image
FROM python:3.11.3-alpine3.17 as web-base
FROM ${PYTHON_IMAGE} as web-base

COPY --from=web-venv-builder /venv /venv

Expand Down
2 changes: 1 addition & 1 deletion docs
Submodule docs updated from ac4e17 to 31f325
3 changes: 1 addition & 2 deletions fiesta/apps/accounts/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from django_htmx.http import HttpResponseClientRedirect


class SocialAccountAdapter(DefaultSocialAccountAdapter):
...
class SocialAccountAdapter(DefaultSocialAccountAdapter): ...


class AccountAdapter(DefaultAccountAdapter):
Expand Down
3 changes: 1 addition & 2 deletions fiesta/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@ def get_queryset(self, request):


@admin.register(EmailAddress)
class FiestaEmailAddressAdmin(EmailAddressAdmin):
... # to have it in accounts admin
class FiestaEmailAddressAdmin(EmailAddressAdmin): ... # to have it in accounts admin
6 changes: 2 additions & 4 deletions fiesta/apps/buddy_system/views/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ def get_request_queryset(cls, request: HttpRequest):
return request.membership.section.buddy_system_requests


class IssuerPictureServeView(ServeFilesFromBuddiesMixin, BaseIssuerPictureServeView):
...
class IssuerPictureServeView(ServeFilesFromBuddiesMixin, BaseIssuerPictureServeView): ...


class MatcherPictureServeView(
ServeFilesFromBuddiesMixin,
BaseMatcherPictureServeView,
):
...
): ...
1 change: 0 additions & 1 deletion fiesta/apps/dashboard/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class DashboardConfiguration(BasePluginConfiguration):
...

class Meta:
verbose_name = _("dashboard configuration")
Expand Down
5 changes: 1 addition & 4 deletions fiesta/apps/events/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class State(models.TextChoices):


def has_permission_for_cover_photo_view(request: HttpRequest, name: str) -> bool: # TODO
if request.user.is_authenticated:
return True

return False
return request.user.is_authenticated


class Event(BaseTimestampedModel):
Expand Down
7 changes: 2 additions & 5 deletions fiesta/apps/events/models/price_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ def is_available(self, variant: PriceVariant, user: User):
if to_ is not None and to_ != "" and to_ > datetime.now(UTC):
return False

if variant.type == self.STANDARD or (
return variant.type == self.STANDARD or (
variant.type == self.WITH_ESN_CARD
and user.profile_or_none is not None
and user.profile.is_esn_card_holder()
):
return True

return False
)


class PriceVariant(BaseModel):
Expand Down
3 changes: 1 addition & 2 deletions fiesta/apps/fiestarequests/matching_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def can_member_match(self, membership: SectionMembership) -> bool:
def on_created_request(
self,
request: BuddyRequest,
) -> None:
...
) -> None: ...

@classmethod
def _base_filter(cls, membership: SectionMembership) -> Q:
Expand Down
1 change: 0 additions & 1 deletion fiesta/apps/fiestatables/views/htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ def get_context_data(self, **kwargs):
except EmptyPage:
if self.request.GET.get("page"):
...
...
1 change: 0 additions & 1 deletion fiesta/apps/pages/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class PagesConfiguration(BasePluginConfiguration):
...

class Meta:
verbose_name = _("pages configuration")
Expand Down
6 changes: 2 additions & 4 deletions fiesta/apps/pickup_system/views/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ def get_request_queryset(cls, request: HttpRequest):
return request.membership.section.pickup_system_requests


class IssuerPictureServeView(ServeFilesFromPickupsMixin, BaseIssuerPictureServeView):
...
class IssuerPictureServeView(ServeFilesFromPickupsMixin, BaseIssuerPictureServeView): ...


class MatcherPictureServeView(
ServeFilesFromPickupsMixin,
BaseMatcherPictureServeView,
):
...
): ...
2 changes: 1 addition & 1 deletion fiesta/apps/plugins/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __str__(self):

def clean(self):
# cannot use isinstance, since children are allowed to create
if type(self) == BasePluginConfiguration:
if type(self) == BasePluginConfiguration: # noqa: E721
raise ValidationError(_("Base plugin configuration cannot be saved directly, only children."))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _check_for_plugin(self, plugin: Plugin):
# }

match plugin.app_config:
case (BuddySystemConfig() | PickupSystemConfig()):
case BuddySystemConfig() | PickupSystemConfig():
self._check_field_dependency(
plugin=plugin,
field_value=sections_conf.required_faculty,
Expand Down
7 changes: 2 additions & 5 deletions fiesta/apps/sections/views/mixins/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ def test_func(self):
# !membership OR (membership.section==in_space_of_section)
return False

if not self.test_membership(membership=membership):
# right section, but without sufficient role
return False

return True
return self.test_membership(membership=membership)
# False = right section, but without sufficient role

def test_membership(self, membership: SectionMembership) -> bool:
raise NotImplementedError("To be overriden")
Expand Down
5 changes: 3 additions & 2 deletions fiesta/apps/utils/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def get_array_display(instance):
for value in getattr(instance, self.attname)
]

if "get_%s_display" % self.name not in cls.__dict__:
method_name = f"get_{self.name}_display"
if method_name not in cls.__dict__:
setattr(
cls,
"get_%s_display" % self.name,
method_name,
get_array_display,
)
1 change: 1 addition & 0 deletions fiesta/fiesta/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

from __future__ import annotations

from django.core.asgi import get_asgi_application
Expand Down
1 change: 1 addition & 0 deletions fiesta/fiesta/checks/fiesta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Checks related to project, usually to keep codestyle."""

from __future__ import annotations

import django
Expand Down
3 changes: 1 addition & 2 deletions fiesta/fiesta/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class Base(
TemplatesConfigMixin,
AdminConfigMixin,
Configuration,
):
...
): ...


class Development(Base):
Expand Down
1 change: 1 addition & 0 deletions fiesta/fiesta/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""

from __future__ import annotations

from django.core.wsgi import get_wsgi_application
Expand Down
Loading

0 comments on commit 8c97d9c

Please sign in to comment.