Skip to content

Commit 970518e

Browse files
authored
Bump Python to 3.11.1 (#532)
This commit bumps the version of Python we use to run CTMS from 3.10.9 to 3.11.1. In order to complete the upgrade, we also had to: - update `pylint`, and make some related changes - re-add `uvicorn` so we pulled in `uvloop>=0.17`
1 parent f8a4c3d commit 970518e

8 files changed

Lines changed: 78 additions & 102 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
run: pipx install poetry==1.3.2
1212
- uses: actions/setup-python@v4
1313
with:
14-
python-version: "3.10.9"
14+
python-version: "3.11.1"
1515
cache: "poetry"
1616
- name: Install dependencies
1717
run: poetry install

.github/workflows/test-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: pipx install poetry==1.3.2
2929
- uses: actions/setup-python@v4
3030
with:
31-
python-version: "3.10.9"
31+
python-version: "3.11.1"
3232
cache: "poetry"
3333
- name: Install dependencies
3434
run: poetry install

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10.9 as python-base
1+
FROM python:3.11.1 as python-base
22

33
ENV PIP_DEFAULT_TIMEOUT=100 \
44
PIP_DISABLE_PIP_VERSION_CHECK=on \
@@ -16,7 +16,7 @@ WORKDIR $PYSETUP_PATH
1616
COPY ./poetry.lock ./pyproject.toml ./
1717
RUN $POETRY_HOME/bin/poetry install --no-dev --no-root
1818

19-
FROM python:3.10.9-slim as production
19+
FROM python:3.11.1-slim as production
2020

2121
COPY bin/update_and_install_system_packages.sh /opt
2222
RUN opt/update_and_install_system_packages.sh libpq5

ctms/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@
9494

9595
# We could use the default prometheus_client.REGISTRY, but it makes tests
9696
# easier to write if it is possible to replace the registry with a fresh one.
97+
# pylint: disable-next=unnecessary-lambda-assignment
9798
get_metrics_registry = lambda: METRICS_REGISTRY
98-
get_metrics = lambda: METRICS
99+
get_metrics = lambda: METRICS # pylint: disable=unnecessary-lambda-assignment
99100
oauth2_scheme = OAuth2ClientCredentials(tokenUrl="token")
100101
token_scheme = HTTPBasic(auto_error=False)
101102

@@ -359,6 +360,7 @@ def get_pubsub_claim(
359360
):
360361
for name in ("audience", "email", "client"):
361362
if not pubsub_settings[name]:
363+
# pylint: disable-next=broad-exception-raised
362364
raise Exception(f"PUBSUB_{name.upper()} is unset")
363365

364366
credentials_exception = HTTPException(

ctms/ingest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def finalize(self):
2525
missing.append(name)
2626

2727
if missing:
28+
# pylint: disable-next=broad-exception-raised
2829
raise BaseException(f"Must provide data for all tables. Missing {missing}")
2930

3031

ctms/sync.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,17 @@ def check_healthcheck(healthcheck_path, age_s):
205205
Return the current age.
206206
"""
207207
if not healthcheck_path:
208+
# pylint: disable-next=broad-exception-raised
208209
raise Exception("BACKGROUND_HEALTHCHECK_PATH not set")
209210
if age_s is None:
211+
# pylint: disable-next=broad-exception-raised
210212
raise Exception("BACKGROUND_HEALTHCHECK_AGE_S not set")
211213
with open(healthcheck_path, "r", encoding="utf8") as health_file:
212214
content = health_file.read().strip()
213215
written_at = datetime.fromisoformat(content)
214216
health_age_raw = (datetime.now(tz=timezone.utc) - written_at).total_seconds()
215217
health_age = round(health_age_raw, 3)
216218
if health_age > age_s:
219+
# pylint: disable-next=broad-exception-raised
217220
raise Exception(f"Age {health_age}s > {age_s}s, written at {content}")
218221
return health_age

poetry.lock

Lines changed: 64 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = ["CTMS Reviewers <@mozilla-it/ctms-reviewers>"]
1111

1212
[tool.poetry.dependencies]
1313
# These packages are mandatory and form the core of this package’s distribution.
14-
python = "3.10.9"
14+
python = "3.11.1"
1515
fastapi = "^0.84.0"
1616
starlette = "^0.19.1"
1717
requests = "^2.28.1"
@@ -46,7 +46,7 @@ types-python-dateutil = "^2.8.19"
4646
detect-secrets = "^1.4.0"
4747
bandit = "^1.7.0"
4848
SQLAlchemy-Utils = "^0.39.0"
49-
pylint = "^2.13.9"
49+
pylint = "^2.16.0"
5050
pylint-pytest = "^1.1.2"
5151
types-requests = "^2.28.11"
5252

@@ -58,18 +58,13 @@ testpaths = [
5858
[tool.pylint]
5959
[tool.pylint.'MESSAGES CONTROL']
6060
disable = [
61-
# https://black.readthedocs.io/en/stable/compatible_configs.html
62-
"C0330",
63-
"C0326",
64-
6561
"R0801", # sqla has a lot of duplicate code and it is work to "fix" this
6662
"C0301", # if black is happy with the line-length, let's not mess with it
6763
"R0903", # this is triggered by pydantic's config and is really just a taste thing anyway
6864
"R0913", # we have too-many-arguments in too many places to easily fix
6965
"R0912", # Same idea as above, let's leave it since it is a matter of taste
7066
"W0511", # Let us have our TODOs
7167
"W0613", # sometimes unused arguments are nice for symmetry and also api methods
72-
"R0201", # Not using "self" when it is defined is a matter of taste
7368
"R0914", # Leave me alone, pylint. I can have as many locals as I want
7469

7570
"C0114", # mozilla-it/ctms-api#100
@@ -120,7 +115,7 @@ profile = "black"
120115

121116
[tool.mypy]
122117
# Sync Python version with Dockerfile
123-
python_version = "3.10.9"
118+
python_version = "3.11"
124119
# Look for errors in this file
125120
warn_unused_configs = true
126121

0 commit comments

Comments
 (0)