Skip to content

Commit

Permalink
Merge pull request #16 from makinacorpus/setup_ci
Browse files Browse the repository at this point in the history
Setup linting with github ci
  • Loading branch information
gbip authored Feb 10, 2025
2 parents 4106961 + 530d318 commit 888ff9d
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyproject.toml export-subst
85 changes: 85 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Lint source code

on:
push:
branches: [ $default-branch ]
pull_request:

jobs:

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: psf/black@stable
with:
version: "~= 24.0"

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for versioningit to find the repo version
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install --upgrade pip build
- name: Build python package
run: python -m build

mypy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for versioningit to find the repo version
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python -m pip install .[drf]

- name: Install dependencies
run: python -m pip install --upgrade pip
-r requirements/requirements-dev.in
-r requirements/requirements-test.in

- name: Run mypy
run: mypy --version && ./run_mypy.sh


linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for versioningit to find the repo version
- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: python -m pip download .[drf]

- name: Install dependencies
run: python -m pip install --upgrade pip
-r requirements/requirements-dev.in
-r requirements/requirements-test.in

- name: Run flake8
run : flake8 --version && flake8 --extend-ignore=E501,E503,E203 --max-line-len=88 .

- name: Run isort
run : isort --profile black .
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
1 change: 1 addition & 0 deletions django_pyoidc/providers/keycloak_10.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Base Keycloak Provider class.
"""

from typing import Any, Optional
from urllib.parse import urlparse

Expand Down
6 changes: 3 additions & 3 deletions django_pyoidc/providers/keycloak_18.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Keycloak18Provider(Keycloak17Provider):
def get_default_config(self) -> ProviderConfig:
result = super().get_default_config()
# logout redirection query string parameter name altered, from redirect_uri to post_logout_redirect_uri
result[
"oidc_logout_query_string_redirect_parameter"
] = "post_logout_redirect_uri"
result["oidc_logout_query_string_redirect_parameter"] = (
"post_logout_redirect_uri"
)
return result
2 changes: 1 addition & 1 deletion django_pyoidc/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Rare usages ---
"client_authn_method": Optional[bool],
"oidc_logout_query_string_redirect_parameter": Optional[str],
"oidc_logout_query_string_extra_parameters_dict": Optional[Dict[str, Any]]
"oidc_logout_query_string_extra_parameters_dict": Optional[Dict[str, Any]],
# "client_consumer_config_dict": None,
# some providers may return even more stuff (...) ---
},
Expand Down
Empty file added django_pyoidc/py.typed
Empty file.
4 changes: 3 additions & 1 deletion django_pyoidc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def post(self, request: HttpRequest) -> HttpResponse:
if sid:
try:
client = OIDCClient(self.op_name, session_id=sid)
except Exception as e: # FIXME : Finer exception handling (KeyError,ParseError,CommunicationError)
except (
Exception
) as e: # FIXME : Finer exception handling (KeyError,ParseError,CommunicationError)
logger.error("OIDC Logout call error when loading OIDC state: ")
logger.exception(e)

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,3 @@ source = "versioningit"

[tool.versioningit.vcs]
method = "git"

6 changes: 4 additions & 2 deletions requirements/requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

pip-tools
pre-commit
ruff
mypy
isort
flake8
black
mypy==1.11.2
djangorestframework-stubs[compatible-mypy]
django-stubs[compatible-mypy]
types-Markdown
Expand Down
1 change: 0 additions & 1 deletion tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ def test_callback_calling_hook_validate_access_token(
class BackchannelLogoutTestCase(OIDCTestCase):
@classmethod
def setUpTestData(cls):

"""
To generate an other jwk key : 'jose jwk gen -i '{"alg":"HS256"}' -o oct.jwk'
"""
Expand Down

0 comments on commit 888ff9d

Please sign in to comment.