Skip to content

Commit

Permalink
KIT-3696 Update to Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
fabsalamov committed Sep 12, 2024
1 parent 229ab0b commit 32e3db1
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://github.com/devcontainers/images/tree/main/src/python
FROM mcr.microsoft.com/devcontainers/python:3.8-bullseye
FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm

# Uninstall pre-installed formatting and linting tools
# They would conflict with our pinned versions
Expand Down
49 changes: 21 additions & 28 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "sag_py_web_common",
"name": "AP-Prediction",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
Expand All @@ -10,46 +10,39 @@
"python.pythonPath": "/usr/local/bin/python",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/home/vscode/.local/bin/flake8",
"flake8.importStrategy": "fromEnvironment",
"python.linting.mypyPath": "/home/vscode/.local/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
"flake8.path": [
"/usr/local/py-utils/bin/bandit",
"/usr/local/py-utils/bin/pydocstyle"
],
"flake8.importStrategy": "fromEnvironment"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.flake8",
"AykutSarac.jsoncrack-vscode",
"eamodio.gitlens",
"geeebe.duplicate",
"Gruntfuggly.todo-tree",
"matangover.mypy",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"usernamehw.errorlens",
"sourcery.sourcery",
"njqdev.vscode-python-typehint",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"njpwerner.autodocstring",
"njqdev.vscode-python-typehint",
"redhat.vscode-yaml",
"visualstudioexptteam.vscodeintellicode",
"kaih2o.python-resource-monitor",
"geeebe.duplicate",
"oderwat.indent-rainbow",
"shardulm94.trailing-spaces",
"streetsidesoftware.code-spell-checker",
"ryanluker.vscode-coverage-gutters",
"spmeesseman.vscode-taskexplorer",
"eamodio.gitlens",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml",
"AykutSarac.jsoncrack-vscode",
"yzhang.markdown-all-in-one",
"Gruntfuggly.todo-tree"
"visualstudioexptteam.vscodeintellicode",
"yzhang.markdown-all-in-one"
]
}
},
"initializeCommand": "powershell.exe .\\.devcontainer\\initialize.ps1",
"postCreateCommand": "pip3 install -r ${containerWorkspaceFolder}/requirements-dev.txt",
"postCreateCommand": "python -m pip install --upgrade pip; pip3 install -r ${containerWorkspaceFolder}/requirements-dev.txt",
"remoteUser": "vscode",
"mounts": [
"source=${localEnv:USERPROFILE}/_devcontainer/cache,target=/home/vscode/.cache,type=bind"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.12"
- name: Add linting matchers
run: |
echo "::add-matcher::.github/flake8-error-problem-matcher.json"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.12"
- run: >-
python -m
pip install
Expand Down
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Used by cli, vscode and pycharm
# https://mypy.readthedocs.io/en/stable/config_file.html?highlight=follow_imports#confval-follow_imports
[mypy]
python_version = 3.8
python_version = 3.12
exclude = (?x)(
venv/
| build/
Expand Down
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[FORMAT]
max-line-length=120

[MESSAGES CONTROL]
disable=C0114, C0115, C0116
8 changes: 0 additions & 8 deletions .sourcery.yaml

This file was deleted.

62 changes: 40 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,64 @@
"editor.rulers": [
120
],
"files.trimTrailingWhitespace": true,
"files.exclude": {
".coverage": true,
".flake8": true,
".gitattributes": true,
".gitignore": true,
".idea": true,
".mypy_cache": true,
"**/.pytest_cache": true,
".mypy.ini": true,
".pylintrc": true,
"*.egg-info": true,
"**/__pycache__": true,
".coverage": true,
"**/.pytest_cache": true,
"coverage.xml": true,
"htmlcov": true,
"venv": true
"venv": true,
},
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": [ "--line-length=120" ],
"[python]": { "editor.formatOnSave": true },
"[json]": { "editor.formatOnSave": true},
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
},
"python.linting.mypyEnabled": true,
"mypy.targets": [
// Required by dmypy - otherwise mypy has an error in vscode
"--follow-imports=normal",
"."
"isort.args": [
"--profile",
"black",
"--line-length",
"120"
],
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.diagnosticSeverityOverrides": {
"reportPrivateUsage": "information",
},
"errorLens.enabledDiagnosticLevels": [
"error",
"warning"
"black-formatter.args": [
"--line-length=120"
],
"[json]": {
"editor.formatOnSave": true
},
"mypy.targets": [
// Required by dmypy - otherwise mypy has an error in vscode
"--follow-imports=normal",
"."
],
"todo-tree.general.showActivityBarBadge": true,
"todo-tree.general.statusBar": "current file"
"todo-tree.general.statusBar": "current file",
"cSpell.words": [
"fastapi",
"ndarray",
"pydantic",
"Starlette",
"tessdata",
"tesseract",
"uvicorn"
]
}
12 changes: 11 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
"reveal": "always",
"panel": "new"
}
}
},
{
"label": "Format all",
"type": "shell",
"command": "black . -l 120",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "sag-py-web-common"
version = "0.1.3"
version = "1.0.0"
description = "Small helper functions for web projects"
authors = ["Samhammer AG"]
license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8.2"
python = "^3.12"
asgi-logger = "^0.1.0"
fastapi = "^0.110.3"

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ pytest-cov
# see for details: https://github.com/theupdateframework/python-tuf/issues/2254
coverage-lcov
toml
coverage==6.5.0
coverage
4 changes: 1 addition & 3 deletions sag_py_web_common/filtered_access_logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict

from asgi_logger.middleware import AccessInfo, AccessLogAtoms, AccessLoggerMiddleware
from asgiref.typing import ASGIReceiveCallable, ASGISendCallable, HTTPScope

Expand All @@ -24,7 +22,7 @@ def _should_log(self, scope: HTTPScope) -> bool:
return scope["type"] == "http" and not self._has_health_check_header(scope)

def _has_health_check_header(self, scope: HTTPScope) -> bool:
header_dict: Dict[bytes, bytes] = dict(scope["headers"])
header_dict: dict[bytes, bytes] = dict(scope["headers"])
return b"healthcheck" in header_dict and header_dict[b"healthcheck"] in {
b"livenessprobe",
b"readinessprobe",
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setuptools.setup(
name="sag-py-web-common",
version="0.1.3",
version="1.0.0",
description="Small helper functions for web projects",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
Expand All @@ -30,7 +30,7 @@
keywords="fastapi, web, helper, common",
packages=setuptools.find_packages(exclude=["tests"]),
package_data={"sag_py_web_common": ["py.typed"]},
python_requires=">=3.8",
python_requires=">=3.12",
install_requires=REQS,
extras_require={"dev": REQS_DEV},
project_urls={
Expand Down

0 comments on commit 32e3db1

Please sign in to comment.