Skip to content
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

Bump Python from 3.9.9 to 3.11 #11789

Merged
merged 8 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
7 changes: 2 additions & 5 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9.9
python-version: 3.11
cache: "pip"
- uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -108,9 +108,6 @@ jobs:
run: mypy network-api
- name: Run Tests
run: cd network-api && pytest -n auto -v --ds=networkapi.settings -cov=network-api/networkapi --cov-report=term-missing
- name: Coveralls
run: coveralls
continue-on-error: true

test_integration:
name: Integration testing
Expand Down Expand Up @@ -155,7 +152,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9.9
python-version: 3.11

cache: "pip"
- uses: actions/setup-node@v3
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN npm run build
# Note: This stage builds the base image for production. Presently we are not
# using this on the production site, but only use it as base for the dev build.
# Pin "bullseye" as it matches Ubuntu 20.04 -- Heroku 20 stack currently used in production.
FROM python:3.9.9-slim-bullseye as base
FROM python:3.11-slim-bullseye as base

# Install dependencies in a virtualenv
ENV VIRTUAL_ENV=/app/dockerpythonvenv
Expand Down Expand Up @@ -83,7 +83,7 @@ USER mozilla

# Install your app's Python requirements.
RUN python -m venv $VIRTUAL_ENV
RUN pip install -U pip==20.0.2 && pip install pip-tools
RUN pip install -U pip==23.3.2 && pip install pip-tools
# Normally we won't install dev dependencies in production, but we do it here to optimise
# docker build cache for local build
COPY --chown=mozilla ./requirements.txt ./dev-requirements.txt ./
Expand Down
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Mozilla Foundation site",
"description": "Mozilla Foundation site",
"stack": "heroku-22",
"addons": [
"heroku-postgresql:basic --version=15"
],
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-c requirements.txt
black
coveralls
django-debug-toolbar
djhtml
djlint
Expand Down
44 changes: 3 additions & 41 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile dev-requirements.in
Expand All @@ -10,26 +10,16 @@ asgiref==3.7.2
# django
black==23.11.0
# via -r dev-requirements.in
certifi==2023.7.22
# via
# -c requirements.txt
# requests
charset-normalizer==2.0.12
# via
# -c requirements.txt
# requests
click==8.1.3
# via
# black
# djlint
colorama==0.4.6
# via djlint
coverage[toml]==5.5
coverage[toml]==7.4.1
# via
# coveralls
# coverage
# pytest-cov
coveralls==3.3.1
# via -r dev-requirements.in
cssbeautifier==1.14.7
# via djlint
django==4.2.9
Expand All @@ -42,14 +32,10 @@ djhtml==3.0.6
# via -r dev-requirements.in
djlint==1.19.16
# via -r dev-requirements.in
docopt==0.6.2
# via coveralls
editorconfig==0.12.3
# via
# cssbeautifier
# jsbeautifier
exceptiongroup==1.1.1
# via pytest
execnet==1.9.0
# via pytest-xdist
flake8==6.1.0
Expand All @@ -60,10 +46,6 @@ html-tag-names==0.1.2
# via djlint
html-void-elements==0.1.0
# via djlint
idna==3.3
# via
# -c requirements.txt
# requests
iniconfig==2.0.0
# via pytest
isort==5.13.1
Expand Down Expand Up @@ -121,10 +103,6 @@ pyyaml==6.0.1
# djlint
regex==2022.10.31
# via djlint
requests==2.31.0
# via
# -c requirements.txt
# coveralls
six==1.16.0
# via
# -c requirements.txt
Expand All @@ -137,16 +115,6 @@ sqlparse==0.4.4
# django-debug-toolbar
termcolor==2.3.0
# via pytest-sugar
toml==0.10.2
# via
# -c requirements.txt
# coverage
tomli==2.0.1
# via
# black
# djlint
# mypy
# pytest
tqdm==4.63.0
# via
# -c requirements.txt
Expand All @@ -160,10 +128,4 @@ types-urllib3==1.26.16
typing-extensions==4.4.0
# via
# -c requirements.txt
# asgiref
# black
# mypy
urllib3==1.26.15
# via
# -c requirements.txt
# requests
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.9
python_version = 3.11
ignore_missing_imports = True
follow_imports = silent
exclude = (?x)(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-07-23 17:32
from __future__ import unicode_literals

from django.db import migrations

Expand Down
4 changes: 2 additions & 2 deletions network-api/networkapi/donate_banner/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def test_banner_chooser_exclude_locale(self):
results = response.context["results"]

# Chooser does not include every banner, but only the default langauge oness
self.assertNotEquals(len(results), all_banners.count())
self.assertEquals(len(results), default_banners.count())
self.assertNotEqual(len(results), all_banners.count())
self.assertEqual(len(results), default_banners.count())
self.assertNotIn(translated_banner, results)
self.assertIn(self.banners[0], results)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-07-23 17:33
from __future__ import unicode_literals

import wagtail.fields
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-07-26 03:52
from __future__ import unicode_literals

from django.db import migrations, models

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-03-20 17:47
from __future__ import unicode_literals

from django.db import migrations

Expand Down
2 changes: 0 additions & 2 deletions network-api/networkapi/news/migrations/0003_news_featured.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-04-08 17:52
from __future__ import unicode_literals

from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion network-api/networkapi/s3_file_storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def move(self, old_file_name, new_file_name, allow_overwrite=False):
k = self.bucket.copy_key(new_key_name, self.bucket.name, old_key_name)

if not k:
raise "Couldn't copy '%s' to '%s'" % (old_file_name, new_file_name)
raise "Couldn't copy '{}' to '{}'".format(old_file_name, new_file_name)

self.delete(old_file_name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _localize_category_parent(categories):
"""
BuyersGuideProductCategory = apps.get_model(app_label="wagtailpages", model_name="BuyersGuideProductCategory")

parents_ids = list(set([category.parent.pk for category in categories if category.parent]))
parents_ids = list({category.parent.pk for category in categories if category.parent})
parents = BuyersGuideProductCategory.objects.filter(id__in=parents_ids)
parents = localize_queryset(parents)
parents_cache = {parent.translation_key: parent for parent in parents}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_context(
profile["entry_count"] = False
profile["user_bio_long"] = False

except (IOError, ValueError) as exception:
except (OSError, ValueError) as exception:
print(str(exception))
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_context(self, value, parent_context=None):

profiles = [as_dict[id] for id in ids.split(",") if id in as_dict]

except (IOError, ValueError) as exception:
except (OSError, ValueError) as exception:
print(str(exception))
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_context(self, value, parent_context=None, ordering=False):
profile["entry_count"] = False
profile["user_bio_long"] = False

except (IOError, ValueError) as exception:
except (OSError, ValueError) as exception:
print(str(exception))
pass

Expand Down
2 changes: 1 addition & 1 deletion network-api/networkapi/wagtailpages/pagemodels/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def filter_entries_for_tag(self, entries, context):
if hasattr(entry, "tags") and not
# Determine whether there is any overlap between 'all tags' and
# the tags specified. This effects ANY matching (rather than ALL).
set([tag.slug for tag in entry.tags.all()]).isdisjoint(terms)
{tag.slug for tag in entry.tags.all()}.isdisjoint(terms)
]

return entries
Expand Down
2 changes: 1 addition & 1 deletion network-api/networkapi/wagtailpages/pagemodels/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __str__(self):

def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super(Profile, self).save(*args, **kwargs)
super().save(*args, **kwargs)
self._meta.model.objects.filter(id=self.id).update(slug=Concat(F("slug"), Value("-"), F("id")))

class Meta(TranslatableMixin.Meta):
Expand Down
13 changes: 5 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile
Expand Down Expand Up @@ -137,8 +137,6 @@ html5lib==1.1
# via wagtail
idna==3.3
# via requests
importlib-metadata==6.8.0
# via markdown
jmespath==0.10.0
# via
# boto3
Expand Down Expand Up @@ -242,7 +240,6 @@ tqdm==4.63.0
# via wagtail-inventory
typing-extensions==4.4.0
# via
# asgiref
# dj-database-url
# wagtail-localize
ua-parser==0.18.0
Expand Down Expand Up @@ -292,8 +289,8 @@ webencodings==0.5.1
whitenoise==6.6.0
# via -r requirements.in
willow[heif]==1.6.3
# via wagtail
wrapt==1.13.3
# via
# wagtail
# willow
wrapt==1.16.0
# via scout-apm
zipp==3.16.2
# via importlib-metadata
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.9.9
python-3.11.7
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@

def create_env_file(env_file):
"""Create or update an .env to work with a docker environment"""
with open(env_file, "r") as f:
with open(env_file) as f:
env_vars = f.read()

# We also need to make sure to use the correct db values based on our docker settings.
username = dbname = "postgres"
with open("docker-compose.yml", "r") as d:
with open("docker-compose.yml") as d:
docker_compose = d.read()
username = re.search("POSTGRES_USER=(.*)", docker_compose).group(1) or username
dbname = re.search("POSTGRES_DB=(.*)", docker_compose).group(1) or dbname
Expand Down
Loading