Skip to content

Commit

Permalink
chore: Update python version to 3.11 (#1622)
Browse files Browse the repository at this point in the history
* chore: Update python version to 3.11

* chore: Getting away from passlib and using bcrypt directly

* chore: Moving from python-jose  lib to pyJWT

* fix: Rebase and fix pipfile.lock
  • Loading branch information
rcmerlo authored Oct 16, 2024
1 parent 1c5daea commit 58ef06e
Show file tree
Hide file tree
Showing 42 changed files with 298 additions and 378 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.11"
- name: Install git-secrets in the repository
run: git secrets --install
- name: Install git-secrets aws register in the repository
Expand Down
74 changes: 33 additions & 41 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,27 @@ verify_ssl = true
name = "pypi"

[packages]
redis = "==5.0.8"
alembic = "==1.13.2"
aio-pika = "==9.4.3"
aiofiles = "==24.1.0"
aiohttp = "==3.10.9"
alembic = "==1.13.3"
asyncpg = "==0.29.0"
azure-storage-blob = "==12.22.0"
bcrypt = "==4.2.0"
boto3 = "==1.26.10"
fastapi = "==0.110.3"
# The latest version of the fastapi is not taken because of the issue
# with fastapi-mail that requires 0.21 < starlette < 0.22
# starlette version for those deps ==0.21.0
# with fastapi-mail that requires 0.21 < starlette < 0.22

fastapi-mail = "==1.2.9"
firebase-admin = "==6.5.0"
httpx = "==0.27.2"
jinja2 = "==3.1.4"
bcrypt = "==4.2.0"
passlib = { version = "==1.7.4", extras = ["bcrypt"] }
pyOpenSSL = "==24.2.1"
pydantic = { extras = ["email"], version = "==1.10.18" }
python-jose = { version = "==3.3.0", extras = ["cryptography"] }
python-multipart = "==0.0.9"
sentry-sdk = "~=2.13"
sqlalchemy = { extras = ["asyncio"], version = "==1.4.53" }
uvicorn = { extras = ["standard"], version = "==0.30.6" }
taskiq = { extras = ["reload"], version = "==0.11.7" }
aiohttp = "==3.10.5"
firebase-admin = "==6.5.0"
aio-pika = "==9.4.3"
azure-storage-blob = "==12.22.0"
taskiq-fastapi = "==0.3.2"
taskiq-redis = "==1.0.0"
taskiq-aio-pika = "==0.4.1"
sqlalchemy-utils = "==0.41.2"
typer = "==0.12.5"
aiofiles = "==24.1.0"
nh3 = "==0.2.18"
opentelemetry-api = "==1.27.0"
opentelemetry-sdk = "==1.27.0"
opentelemetry-exporter-otlp = "==1.27.0"
opentelemetry-distro = "==0.48b0"
opentelemetry-exporter-otlp = "==1.27.0"
opentelemetry-instrumentation = "==0.48b0"
opentelemetry-instrumentation-asgi = "==0.48b0"
opentelemetry-instrumentation-asyncio = "==0.48b0"
Expand All @@ -49,51 +35,57 @@ opentelemetry-instrumentation-sqlite3 = "==0.48b0"
opentelemetry-instrumentation-tortoiseorm = "==0.48b0"
opentelemetry-instrumentation-urllib = "==0.48b0"
opentelemetry-instrumentation-wsgi = "==0.48b0"
opentelemetry-propagator-aws-xray = "==1.0.2"
opentelemetry-sdk = "==1.27.0"
opentelemetry-sdk-extension-aws = "==2.0.2"
opentelemetry-semantic-conventions = "==0.48b0"
opentelemetry-test-utils = "==0.48b0"
opentelemetry-util-http = "==0.48b0"
opentelemetry-propagator-aws-xray = "==1.0.2"
opentelemetry-sdk-extension-aws = "==2.0.2"
nh3 = "==0.2.18"
pyOpenSSL = "==24.2.1"
pydantic = { extras = ["email"], version = "==1.10.18" }
pymongo = "*"
python-multipart = "==0.0.12"
redis = "==5.1.0"
sentry-sdk = "~=2.13"
sqlalchemy = { extras = ["asyncio"], version = "==1.4.53" }
sqlalchemy-utils = "==0.41.2"
taskiq = { extras = ["reload"], version = "==0.11.7" }
taskiq-aio-pika = "==0.4.1"
taskiq-fastapi = "==0.3.2"
taskiq-redis = "==1.0.2"
typer = "==0.12.5"
uvicorn = { extras = ["standard"], version = "==0.30.6" }
pyjwt = "==2.9.0"

[dev-packages]
# Nobody knows for what its needed
ipdb = "==0.13.13"
pudb = "==2024.1.2"
# Linters and Formatters
pre-commit = "==3.8.0"
ruff = "==0.6.4"
# Tests
ruff = "==0.6.8"
allure-pytest = "==2.13.5"
pydantic-factories = "==1.17.3"
pytest = "==8.3.3"
pytest-asyncio = "~=0.19"
pytest-cov = "==5.0.0"
pytest-env = "==1.1.4"
pytest-env = "==1.1.5"
pytest-lazy-fixtures = "==1.1.1"
pytest-mock = "==3.14.0"
nest-asyncio = "==1.6.0"
gevent = "==24.2.1"
# MyPy
mypy = "==1.11.2"
types-passlib = "==1.7.7.20240819"
types-python-dateutil = "==2.9.0.20240906"
types-python-jose = "==3.3.4.20240106"
typing-extensions = "==4.12.2"
types-requests = "==2.32.0.20240712"
types-pytz = "==2024.1.0.20240417"
types-requests = "==2.32.0.20240914"
types-pytz = "==2024.2.0.20240913"
types-aiofiles = "==24.1.0.20240626"
types-cachetools = "==5.5.0.20240820"
# https://github.com/sqlalchemy/sqlalchemy/issues/7714
greenlet = "==3.1.0"
# JSONLD deps only for dev
reproschema = "*"
cachetools = "==5.3.0"
pyld = "==2.0.4"

[requires]
python_version = "3.10"
python_version = "3.11"

[scripts]
cli = "python src/cli.py"
367 changes: 145 additions & 222 deletions Pipfile.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ See MindLogger's [Knowledge Base article](https://mindlogger.atlassian.net/servi

## Technologies

-[Python3.10+](https://www.python.org/downloads/release/python-3108/)
-[Python3.11+](https://www.python.org/downloads/release/python-31110/)
-[Pipenv](https://pipenv.pypa.io/en/latest/)
-[FastAPI](https://fastapi.tiangolo.com)
-[Postgresql](https://www.postgresql.org/docs/14/index.html)
Expand All @@ -61,7 +61,7 @@ And

### Prerequisites

- Python 3.10
- Python 3.11
- [Docker](https://docs.docker.com/get-docker/)

#### Recommended Extras
Expand All @@ -71,7 +71,7 @@ Installing [pyenv](https://github.com/pyenv/pyenv) is recommended to automatical
Alternatively, on macOS you can use a tool like [Homebrew](https://brew.sh/) to install multiple versions and specify when creating the virtual environment:

```bash
pipenv --python /opt/homebrew/bin/python3.10
pipenv --python /opt/homebrew/bin/python3.11
```

### Environment Variables
Expand Down Expand Up @@ -189,14 +189,15 @@ Create your virtual environment:
pipenv shell
```

If `pyenv` is installed Python 3.10 should automatically be installed in the virtual environment, you can check the correct version of Python is active by running:
If `pyenv` is installed Python 3.11 should automatically be installed in the virtual environment, you can check the
correct version of Python is active by running:
```bash
python --version
```

If the active version is **not** 3.10, you can manually specify a version while creating your virtual environment:
If the active version is **not** 3.11, you can manually specify a version while creating your virtual environment:
```bash
pipenv --python /opt/homebrew/bin/python3.10
pipenv --python /opt/homebrew/bin/python3.11
```

Install all dependencies
Expand Down
8 changes: 4 additions & 4 deletions compose/fastapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.10-slim-bookworm AS base
FROM python:3.11-slim-bookworm AS base

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH="src/"

WORKDIR /app/

RUN apt-get -y update && apt-get -y upgrade \
&& apt-get install --no-install-recommends -y build-essential=12.9 curl=7.88* libffi-dev \
&& apt-get install --no-install-recommends -y build-essential curl libffi-dev \
&& rm -rf /var/lib/apt/lists/

# Add local non-root user to avoid issue with files
Expand Down Expand Up @@ -67,8 +67,8 @@ FROM base AS worker

USER root
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ffmpeg=7:5.1* \
imagemagick=8:6.9* \
ffmpeg \
imagemagick \
&& rm -rf /var/lib/apt/lists/

USER code
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ omit = [
[tool.mypy]
plugins = ["pydantic.mypy"]
ignore_missing_imports = true
python_version = '3.10'
python_version = '3.11'
mypy_path = 'src'
files = ['*.py']
warn_redundant_casts = true
Expand Down
4 changes: 2 additions & 2 deletions src/apps/activities/domain/conditional_logic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from enum import Enum
from enum import StrEnum

from pydantic import Field

from apps.activities.domain.conditions import Condition
from apps.shared.domain import PublicModel


class Match(str, Enum):
class Match(StrEnum):
ANY = "any"
ALL = "all"

Expand Down
24 changes: 12 additions & 12 deletions src/apps/activities/domain/conditions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import datetime
from enum import Enum
from enum import StrEnum
from typing import Any, Dict, Optional

from pydantic import Field, root_validator, validator

from apps.shared.domain import PublicModel, PublicModelNoExtra


class ConditionType(str, Enum):
class ConditionType(StrEnum):
INCLUDES_OPTION = "INCLUDES_OPTION"
NOT_INCLUDES_OPTION = "NOT_INCLUDES_OPTION"
EQUAL_TO_OPTION = "EQUAL_TO_OPTION"
Expand All @@ -21,7 +21,7 @@ class ConditionType(str, Enum):
EQUAL_TO_SCORE = "EQUAL_TO_SCORE"


class DateConditionType(str, Enum):
class DateConditionType(StrEnum):
GREATER_THAN_DATE = "GREATER_THAN_DATE"
LESS_THAN_DATE = "LESS_THAN_DATE"
EQUAL_TO_DATE = "EQUAL_TO_DATE"
Expand All @@ -30,7 +30,7 @@ class DateConditionType(str, Enum):
OUTSIDE_OF_DATES = "OUTSIDE_OF_DATES"


class TimeRangeConditionType(str, Enum):
class TimeRangeConditionType(StrEnum):
GREATER_THAN_TIME_RANGE = "GREATER_THAN_TIME_RANGE"
LESS_THAN_TIMES_RANGE = "LESS_THAN_TIME_RANGE"
BETWEEN_TIMES_RANGE = "BETWEEN_TIMES_RANGE"
Expand All @@ -39,7 +39,7 @@ class TimeRangeConditionType(str, Enum):
OUTSIDE_OF_TIMES_RANGE = "OUTSIDE_OF_TIMES_RANGE"


class TimeConditionType(str, Enum):
class TimeConditionType(StrEnum):
GREATER_THAN_TIME = "GREATER_THAN_TIME"
LESS_THAN_TIME = "LESS_THAN_TIME"
BETWEEN_TIMES = "BETWEEN_TIMES"
Expand All @@ -48,27 +48,27 @@ class TimeConditionType(str, Enum):
OUTSIDE_OF_TIMES = "OUTSIDE_OF_TIMES"


class MultiSelectConditionType(str, Enum):
class MultiSelectConditionType(StrEnum):
INCLUDES_OPTION = "INCLUDES_OPTION"
NOT_INCLUDES_OPTION = "NOT_INCLUDES_OPTION"


class MultiSelectionsPerRowConditionType(str, Enum):
class MultiSelectionsPerRowConditionType(StrEnum):
INCLUDES_ROW_OPTION = "INCLUDES_ROW_OPTION"
NOT_INCLUDES_ROW_OPTION = "NOT_INCLUDES_ROW_OPTION"


class SingleSelectionPerRowConditionType(str, Enum):
class SingleSelectionPerRowConditionType(StrEnum):
EQUAL_TO_ROW_OPTION = "EQUAL_TO_ROW_OPTION"
NOT_EQUAL_TO_ROW_OPTION = "NOT_EQUAL_TO_ROW_OPTION"


class SingleSelectConditionType(str, Enum):
class SingleSelectConditionType(StrEnum):
EQUAL_TO_OPTION = "EQUAL_TO_OPTION"
NOT_EQUAL_TO_OPTION = "NOT_EQUAL_TO_OPTION"


class SliderRowConditionType(str, Enum):
class SliderRowConditionType(StrEnum):
GREATER_THAN_SLIDER_ROWS = "GREATER_THAN_SLIDER_ROWS"
LESS_THAN_SLIDER_ROWS = "LESS_THAN_SLIDER_ROWS"
EQUAL_TO_SLIDER_ROWS = "EQUAL_TO_SLIDER_ROWS"
Expand All @@ -77,7 +77,7 @@ class SliderRowConditionType(str, Enum):
OUTSIDE_OF_SLIDER_ROWS = "OUTSIDE_OF_SLIDER_ROWS"


class SliderConditionType(str, Enum):
class SliderConditionType(StrEnum):
GREATER_THAN = "GREATER_THAN"
LESS_THAN = "LESS_THAN"
EQUAL = "EQUAL"
Expand All @@ -86,7 +86,7 @@ class SliderConditionType(str, Enum):
OUTSIDE_OF = "OUTSIDE_OF"


class TimePayloadType(str, Enum):
class TimePayloadType(StrEnum):
START_TIME = "startTime"
END_TIME = "endTime"

Expand Down
6 changes: 3 additions & 3 deletions src/apps/activities/domain/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum

__all__ = ["InputType"]

from enum import StrEnum


class InputType(str, Enum):
class InputType(StrEnum):
RADIOBUTTON = "radiobutton"
CHECKBOX = "checkbox"
Loading

0 comments on commit 58ef06e

Please sign in to comment.