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

chore: upgrade python to 3.11 🐍 #22932

Merged
merged 48 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
595927e
3.11
aspicer Jun 12, 2024
41cf645
push
aspicer Jun 12, 2024
3b21fbc
3.11
aspicer Jun 12, 2024
74a8e30
update
aspicer Jun 12, 2024
2ae8c84
dockerfile changes
aspicer Jun 14, 2024
c645dd1
merge
aspicer Jun 14, 2024
a73d843
Merge remote-tracking branch 'origin/master' into aspicer/3.11
aspicer Jun 14, 2024
e49560e
remove uid
aspicer Jun 14, 2024
9526708
lxml upgrade
aspicer Jun 14, 2024
acfe178
Merge branch 'aspicer/3.11' of github.com:PostHog/posthog into aspice…
aspicer Jun 14, 2024
5b0a900
requirements.txt
aspicer Jun 14, 2024
b855075
yarl
aspicer Jun 14, 2024
70e8a9b
upgrades
aspicer Jun 14, 2024
7bab5b3
push
aspicer Jun 14, 2024
24c2606
requirements
aspicer Jun 14, 2024
c1d6851
upgrades
aspicer Jun 14, 2024
c012945
djangorestframework upgrade
aspicer Jun 14, 2024
b52345a
StrEnum
aspicer Jun 14, 2024
42c0b8d
Update query snapshots
github-actions[bot] Jun 14, 2024
9fd2eba
strenum
aspicer Jun 14, 2024
fd43a08
Merge remote-tracking branch 'origin/master' into aspicer/3.11
aspicer Jun 14, 2024
d59101a
Merge remote-tracking branch 'origin/aspicer/3.11' into aspicer/3.11
aspicer Jun 14, 2024
c310fb5
bump build version
aspicer Jun 14, 2024
5f1b5df
dockerfile
aspicer Jun 14, 2024
205fb53
remove migration check
aspicer Jun 14, 2024
958f45b
remove migration checking
aspicer Jun 14, 2024
5ae720a
serialier patch
aspicer Jun 14, 2024
6bc98d0
remove serializer in places it doesn't belong
aspicer Jun 14, 2024
dd4d7ed
Update query snapshots
github-actions[bot] Jun 14, 2024
6a28f70
Merge branch 'master' into aspicer/3.11
aspicer Jun 14, 2024
e9b4964
merge
aspicer Jun 18, 2024
3850eb4
merge
aspicer Jun 18, 2024
79424b4
error tracking order
aspicer Jun 18, 2024
e654576
hm
aspicer Jun 18, 2024
4786e20
see why it isn't starting
aspicer Jun 18, 2024
fb938e5
hm
aspicer Jun 18, 2024
5fe14ea
upgdate unit json tpl
aspicer Jun 18, 2024
b814c51
put back
aspicer Jun 18, 2024
fe3a2d5
update requirements
aspicer Jun 18, 2024
a0cc810
fix requirements
aspicer Jun 18, 2024
caafbd7
Merge branch 'master' into aspicer/3.11
aspicer Jun 18, 2024
35ab02f
Merge remote-tracking branch 'origin/master' into aspicer/3.11
aspicer Jun 18, 2024
d674f63
module sdk
aspicer Jun 18, 2024
6c6b5db
true
aspicer Jun 18, 2024
0649f1b
Merge remote-tracking branch 'origin/master' into aspicer/3.11
aspicer Jun 19, 2024
e3ba4a9
Merge remote-tracking branch 'origin/master' into aspicer/3.11
aspicer Jun 21, 2024
7187455
Merge remote-tracking branch 'origin/master' into aspicer/3.11
aspicer Jun 21, 2024
aaad5e7
Merge branch 'master' into aspicer/3.11
aspicer Jun 21, 2024
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# experience as rich as possible. Perhaps later down the line it might be worth
# rolling our own
#
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/python:3.11-bullseye

# Make sure all exit codes on pipes cause failures
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand All @@ -32,7 +32,7 @@
netcat brotli curl \
&& rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \

Check failure on line 35 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/run-backend-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Run Django tests
inputs:
python-version:
required: true
description: Python version, e.g. 3.10.10
description: Python version, e.g. 3.11.9
clickhouse-server-image:
required: true
description: ClickHouse server image tag, e.g. clickhouse/clickhouse-server:latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-backend-update-test-timing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
concurrency: 1
group: 1
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
python-version: '3.10.10'
python-version: '3.11.9'
clickhouse-server-image: 'clickhouse/clickhouse-server:23.12.5.81-alpine'
segment: 'FOSS'
person-on-events: false
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10.10']
python-version: ['3.11.9']
clickhouse-server-image: ['clickhouse/clickhouse-server:23.12.5.81-alpine']
segment: ['Core']
person-on-events: [false, true]
Expand All @@ -242,7 +242,7 @@ jobs:
- segment: 'Temporal'
person-on-events: false
clickhouse-server-image: 'clickhouse/clickhouse-server:23.12.5.81-alpine'
python-version: '3.10.10'
python-version: '3.11.9'
concurrency: 1
group: 1

Expand Down Expand Up @@ -330,7 +330,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-hog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
if: needs.changes.outputs.hog == 'true'
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-plugin-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
if: needs.changes.outputs.plugin-server == 'true'
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.10
python-version: 3.11.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
Expand Down
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.10
python_version = 3.11
plugins =
mypy_django_plugin.main,
mypy_drf_plugin.main,
Expand Down
2 changes: 1 addition & 1 deletion posthog/hogql/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def print_type(self) -> str:
@dataclass(kw_only=True)
class ArrayType(ConstantType):
data_type: ConstantDataType = field(default="array", init=False)
item_type: ConstantType = UnknownType()
item_type: ConstantType = field(default_factory=UnknownType)

def print_type(self) -> str:
return "Array"
Expand Down
15 changes: 6 additions & 9 deletions production.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# Compile and install Node.js dependencies.
COPY ./plugin-server/package.json ./plugin-server/pnpm-lock.yaml ./plugin-server/tsconfig.json ./
COPY ./plugin-server/patches/ ./patches/
RUN apt-get update && \

Check warning on line 52 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -y --no-install-recommends \
"make" \
"g++" \
Expand Down Expand Up @@ -83,7 +83,7 @@
#
# ---------------------------------------------------------
#
FROM python:3.10.10-slim-bullseye AS posthog-build
FROM python:3.11.9-slim-bullseye AS posthog-build
WORKDIR /code
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]

Expand All @@ -91,7 +91,7 @@
# We install those dependencies on a custom folder that we will
# then copy to the last image.
COPY requirements.txt ./
RUN apt-get update && \

Check warning on line 94 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -y --no-install-recommends \
"build-essential" \
"git" \
Expand Down Expand Up @@ -124,7 +124,7 @@
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]

# Fetch the GeoLite2-City database that will be used for IP geolocation within Django.
RUN apt-get update && \

Check warning on line 127 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -y --no-install-recommends \
"ca-certificates" \
"curl" \
Expand All @@ -135,25 +135,22 @@
( curl -s -L "https://mmdbcdn.posthog.net/" --http1.1 | brotli --decompress --output=./share/GeoLite2-City.mmdb ) && \
chmod -R 755 ./share/GeoLite2-City.mmdb


#
# ---------------------------------------------------------
#
# Build a version of the unit docker image for python3.10
# We can remove this step once we are on python3.11
FROM unit:python3.11 as unit
FROM python:3.10-bullseye as unit-131-python-310
frankh marked this conversation as resolved.
Show resolved Hide resolved

FROM unit:python3.11 as unit-132-python-311

# copied from https://github.com/nginx/unit/blob/master/pkg/docker/Dockerfile.python3.11
LABEL org.opencontainers.image.title="Unit (python3.10)"
LABEL org.opencontainers.image.title="Unit (python3.11)"
LABEL org.opencontainers.image.description="Official build of Unit for Docker."
LABEL org.opencontainers.image.url="https://unit.nginx.org"
LABEL org.opencontainers.image.source="https://github.com/nginx/unit"
LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images"
LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers <[email protected]>"
LABEL org.opencontainers.image.version="1.31.1"
LABEL org.opencontainers.image.version="1.32.0"

RUN set -ex \

Check warning on line 153 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Use WORKDIR to switch to a directory

Check warning on line 153 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`

Check warning on line 153 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
&& savedAptMark="$(apt-mark showmanual)" \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y ca-certificates mercurial build-essential libssl-dev libpcre2-dev curl pkg-config \
Expand Down Expand Up @@ -224,8 +221,8 @@
&& rm -f /requirements.apt \
&& ln -sf /dev/stdout /var/log/unit.log

COPY --from=unit /usr/local/bin/docker-entrypoint.sh /usr/local/bin/

Check warning on line 224 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

`COPY --from` should reference a previously defined `FROM` alias
COPY --from=unit /usr/share/unit/welcome/welcome.* /usr/share/unit/welcome/

Check warning on line 225 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

`COPY --from` should reference a previously defined `FROM` alias

STOPSIGNAL SIGTERM

Expand All @@ -236,14 +233,14 @@
#
# ---------------------------------------------------------
#
FROM unit-131-python-310
FROM unit-132-python-311
WORKDIR /code
frankh marked this conversation as resolved.
Show resolved Hide resolved
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
ENV PYTHONUNBUFFERED 1

# Install OS runtime dependencies.
# Note: please add in this stage runtime dependences only!
RUN apt-get update && \

Check warning on line 243 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`

Check notice on line 243 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Delete the apt-get lists after installing something
apt-get install -y --no-install-recommends \
"chromium" \
"chromium-driver" \
Expand All @@ -254,7 +251,7 @@
"gettext-base"

# Install NodeJS 18.
RUN apt-get install -y --no-install-recommends \

Check warning on line 254 in production.Dockerfile

View workflow job for this annotation

GitHub Actions / Lint changed Dockerfiles

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
"curl" \
&& \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ flaky==3.7.0
aioresponses==0.7.6
prance==23.06.21.0
openapi-spec-validator==0.7.1 # Needed for prance as a validation backend
yarl==1.9.4
37 changes: 10 additions & 27 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements-dev.txt requirements-dev.in
#
aiohttp==3.9.3
# This file was autogenerated by uv via the following command:
# uv pip compile requirements-dev.in -o requirements-dev.txt
aiohttp==3.9.5
# via
# -c requirements.txt
# aioresponses
Expand All @@ -29,7 +25,6 @@ asttokens==2.4.1
async-timeout==4.0.2
# via
# -c requirements.txt
# aiohttp
# redis
attrs==23.2.0
# via
Expand All @@ -42,7 +37,7 @@ black==23.9.1
# -r requirements-dev.in
# datamodel-code-generator
# inline-snapshot
boto3-stubs[s3]==1.34.84
boto3-stubs==1.34.84
# via -r requirements-dev.in
botocore-stubs==1.34.84
# via boto3-stubs
Expand All @@ -67,7 +62,7 @@ click==8.1.7
# inline-snapshot
colorama==0.4.4
# via pytest-watch
coverage[toml]==5.5
coverage==5.5
# via pytest-cov
cryptography==37.0.2
# via
Expand Down Expand Up @@ -96,23 +91,19 @@ docopt==0.6.2
# via pytest-watch
email-validator==2.0.0.post2
# via pydantic
exceptiongroup==1.2.1
# via
# -c requirements.txt
# pytest
execnet==2.1.1
# via pytest-xdist
executing==2.0.1
# via inline-snapshot
faker==17.5.0
# via -r requirements-dev.in
fakeredis[lua]==2.11.0
fakeredis==2.11.0
# via -r requirements-dev.in
flaky==3.7.0
# via -r requirements-dev.in
freezegun==1.2.2
# via -r requirements-dev.in
frozenlist==1.3.0
frozenlist==1.4.1
# via
# -c requirements.txt
# aiohttp
Expand Down Expand Up @@ -207,7 +198,7 @@ pycparser==2.20
# via
# -c requirements.txt
# cffi
pydantic[email]==2.5.3
pydantic==2.5.3
# via
# -c requirements.txt
# datamodel-code-generator
Expand Down Expand Up @@ -314,14 +305,7 @@ syrupy==4.6.0
toml==0.10.2
# via
# coverage
# datamodel-code-generator
# inline-snapshot
tomli==2.0.1
# via
# black
# django-stubs
# mypy
# pytest
types-awscrt==0.20.9
# via botocore-stubs
types-freezegun==1.1.10
Expand Down Expand Up @@ -360,8 +344,6 @@ types-tzlocal==5.1.0.1
typing-extensions==4.7.1
# via
# -c requirements.txt
# asgiref
# black
# boto3-stubs
# django-stubs
# django-stubs-ext
Expand All @@ -377,7 +359,8 @@ urllib3==1.26.18
# responses
watchdog==2.1.8
# via pytest-watch
yarl==1.7.2
yarl==1.9.4
# via
# -c requirements.txt
# -r requirements-dev.in
# aiohttp
4 changes: 3 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@ openai==1.10.0
tiktoken==0.6.0
nh3==0.2.14
hogql-parser==1.0.14
zxcvbn==4.4.28
zxcvbn==4.4.28
xmlsec==1.3.14
lxml==5.2.2
16 changes: 6 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ aiobotocore==2.7.0
# via
# aioboto3
# s3fs
aiohttp==3.9.3
aiohttp==3.9.5
# via
# -r requirements.in
# aiobotocore
Expand Down Expand Up @@ -40,7 +40,6 @@ async-generator==1.10
# trio-websocket
async-timeout==4.0.2
# via
# aiohttp
# aiokafka
# redis
attrs==23.2.0
Expand Down Expand Up @@ -219,11 +218,9 @@ drf-spectacular==0.27.1
# via -r requirements.in
et-xmlfile==1.1.0
# via openpyxl
exceptiongroup==1.2.1
# via anyio
filelock==3.12.0
# via snowflake-connector-python
frozenlist==1.3.0
frozenlist==1.4.1
# via
# aiohttp
# aiosignal
Expand Down Expand Up @@ -261,6 +258,8 @@ googleapis-common-protos==1.60.0
# via
# google-api-core
# grpcio-status
greenlet==3.0.3
# via sqlalchemy
grpcio==1.57.0
# via
# google-api-core
Expand Down Expand Up @@ -461,7 +460,6 @@ python-dateutil==2.8.2
# pandas
# pendulum
# posthoganalytics
# temporalio
python-dotenv==0.21.0
# via webdriver-manager
python-statsd==2.1.0
Expand Down Expand Up @@ -635,8 +633,6 @@ types-setuptools==69.0.0.0
# via requirements-parser
typing-extensions==4.7.1
# via
# anyio
# asgiref
# dlt
# openai
# psycopg
Expand Down Expand Up @@ -685,9 +681,9 @@ wrapt==1.15.0
# via aiobotocore
wsproto==1.1.0
# via trio-websocket
xmlsec==1.3.13
xmlsec==1.3.14
# via python3-saml
yarl==1.7.2
yarl==1.9.4
# via aiohttp
zxcvbn==4.4.28
# via -r requirements.in
Loading