Skip to content

Commit

Permalink
Skip: Update all non-major dependencies (merge commit)
Browse files Browse the repository at this point in the history
Merge branch 'renovate/all-minor-patch' into 'main'
* revert mypy in pre-commit and fix typing

* reference python 3.11

* remove duplicate mypy from pre-commit

* add typing-extensions module

* don't generate code docs for now

* fix sort  problematic word submitter's

* fix mypy ci

* update pre-commit

* switch to idpyoidc

* Skip: Update all non-major dependencies

See merge request https://gitlab.ci.csc.fi/sds-dev/sd-submit/metadata-submitter/-/merge_requests/831

Approved-by: Joonatan Mäkinen <[email protected]>
Co-authored-by: Stefan Negru <[email protected]>
Co-authored-by: Teemu Kataja <[email protected]>
Merged by Joonatan Mäkinen <[email protected]>
  • Loading branch information
Joonatan Mäkinen committed Feb 14, 2024
2 parents 8c9b4bb + 8aa9e5d commit 7141000
Show file tree
Hide file tree
Showing 63 changed files with 275 additions and 335 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ venv.bak/
metadata_backend/frontend/*
config/*

# oidcrp generated directories that store JWKs
# idpyoidc generated directories that store JWKs
private
static
# ignore pyspelling dictionary
Expand Down
26 changes: 13 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: no-commit-to-branch
args: [--branch, develop, --branch, master]
Expand All @@ -29,27 +29,27 @@ repos:
exclude: tests/test_files/study/SRP000539_invalid[0-9]?.xml

- repo: https://github.com/psf/black
rev: 23.10.0
rev: 24.1.1
hooks:
- id: black
args: [-l, "120"]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [--profile, black, --filter-files]

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- flake8-annotations

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.7
hooks:
- id: bandit
files: ^metadata_backend
Expand All @@ -62,7 +62,7 @@ repos:
files: docs/openapi.yml

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: 0.28.0
hooks:
- id: check-metaschema
name: Validate schemas
Expand Down Expand Up @@ -104,13 +104,6 @@ repos:
-sn, # Don't display the score
]

- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
files: ^metadata_backend

- id: pyspelling-docs
name: pyspelling-docs
entry: ./scripts/dictionary/pyspelling.sh
Expand All @@ -119,6 +112,13 @@ repos:
types_or: [markdown, rst]
require_serial: true

- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
files: ^metadata_backend

- id: pyspelling-schemas
name: pyspelling-schemas
entry: ./scripts/dictionary/pyspelling.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Service also validates submitted metadata objects against EGA XSD metadata model
## Install and run

### Requirements:
- Python 3.8+
- Python 3.11+
- MongoDB
- Docker + docker-compose

Expand Down
69 changes: 0 additions & 69 deletions docs/code.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/dictionary/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ identifiertype
identitypython
ido
idp
idpyoidc
ietf
igbo
igsn
Expand Down
3 changes: 0 additions & 3 deletions docs/submitter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,3 @@ The REST API is protected and can be accessed in two ways:
.. important:: A logged in user can only perform operations on the data it has associated.
The information for the current user can be retrieved at ``/v1/users/current`` (the user ID is ``current``), and
any additional operations on other users are rejected.


.. include:: code.rst
1 change: 1 addition & 0 deletions examples/create_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
3. Generate a token with the instructions in this script
4. Use the token as a Bearer token, with `valid=timestamp` and `userId=user_id` query parameters
"""

import hmac
import time

Expand Down
12 changes: 6 additions & 6 deletions metadata_backend/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from aiohttp import web
from aiohttp.client_exceptions import ClientConnectorError, InvalidURL
from aiohttp.web import Request, Response
from oidcrp.exception import OidcServiceError # type: ignore[import, unused-ignore]
from oidcrp.rp_handler import RPHandler # type: ignore[import, unused-ignore]
from idpyoidc.client.rp_handler import RPHandler # type: ignore[import, unused-ignore]
from idpyoidc.exception import OidcMsgError # type: ignore[import, unused-ignore]
from yarl import URL

from ..conf.conf import aai_config
Expand Down Expand Up @@ -55,7 +55,7 @@ def __init__(self, aai: dict[str, Any]) -> None:
"add_ons": {
# Re-activate this once we have implemented support on AAI side
# "dpop": {
# "function": "oidcrp.oauth2.add_on.dpop.add_support",
# "function": "idpyoidc.client.oauth2.add_on.dpop.add_support",
# "kwargs": {
# "signing_algorithms": [
# "ES256",
Expand All @@ -64,7 +64,7 @@ def __init__(self, aai: dict[str, Any]) -> None:
# },
# },
"pkce": {
"function": "oidcrp.oauth2.add_on.pkce.add_support",
"function": "idpyoidc.client.oauth2.add_on.pkce.add_support",
"kwargs": {
"code_challenge_length": 64,
"code_challenge_method": "S256",
Expand All @@ -88,7 +88,7 @@ async def login(self, _: Request) -> web.HTTPSeeOther:
session = self.rph.begin("aai")
except Exception as e:
# This can be caused if config is improperly configured, and
# oidcrp is unable to fetch oidc configuration from the given URL
# idpyoidc is unable to fetch oidc configuration from the given URL
LOG.exception("OIDC authorization request failed with: %r", e)
raise web.HTTPInternalServerError(reason="OIDC authorization request failed.")

Expand Down Expand Up @@ -135,7 +135,7 @@ async def callback(self, req: Request) -> Response:
except KeyError as e:
LOG.exception("Issuer: %s not found, failed with: %r.", session["iss"], e)
raise web.HTTPBadRequest(reason="Token issuer not found.")
except OidcServiceError as e:
except OidcMsgError as e:
# This exception is raised if RPHandler encounters an error due to:
# 1. "code" is wrong, so token request failed
# 2. token validation failed
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions shared between handlers."""

import csv
import string
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

import aiohttp_session
from aiohttp import web

Expand Down
3 changes: 2 additions & 1 deletion metadata_backend/api/handlers/object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

from datetime import datetime
from math import ceil
from typing import Any
Expand Down Expand Up @@ -39,7 +40,7 @@ async def _handle_query(self, req: Request) -> Response:

filter_list: list[Any] = [] # DEPRECATED, users don't own submissions anymore
data, page_num, page_size, total_objects = await ObjectOperator(db_client).query_metadata_database(
collection, req.query, page, per_page, filter_list # type: ignore
collection, req.query, page, per_page, filter_list
)

result = ujson.dumps(
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/publish.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

from datetime import date, datetime
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/rems_proxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Get and process REMS data for the frontend."""

from typing import Any, TypedDict

from aiohttp import web
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/restapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

import json
from collections.abc import AsyncIterator, Iterator
from math import ceil
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/static.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

import mimetypes
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/submission.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

from datetime import datetime
from math import ceil
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/handlers/xml_submission.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle HTTP methods for server."""

from collections import Counter
from typing import Any

Expand Down
9 changes: 5 additions & 4 deletions metadata_backend/api/health.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle health check endpoint."""

import time

import ujson
Expand Down Expand Up @@ -81,24 +82,24 @@ async def get_health_status(self, _: Request) -> Response:
body=ujson.dumps(full_status, escape_forward_slashes=False), status=200, content_type="application/json"
)

async def create_test_db_client(self) -> AsyncIOMotorClient:
async def create_test_db_client(self) -> AsyncIOMotorClient: # type: ignore
"""Initialize a new database client to test Mongo connection.
:returns: Coroutine-based Motor client for Mongo operations
"""
new_client = AsyncIOMotorClient(url, connectTimeoutMS=4000, serverSelectionTimeoutMS=4000)
new_client = AsyncIOMotorClient(url, connectTimeoutMS=4000, serverSelectionTimeoutMS=4000) # type: ignore
LOG.debug("Initialised a new DB client as a test")
return new_client

async def try_db_connection(self, db_client: AsyncIOMotorClient) -> None | float:
async def try_db_connection(self, db_client: AsyncIOMotorClient) -> None | float: # type: ignore
"""Check the connection to database.
:param db_client: Motor client used for database connections
:returns: Connection time or None if connection fails
"""
try:
start = time.time()
await db_client.server_info()
await db_client.server_info() # type: ignore
LOG.debug("Connection to db succeeded.")
perf_time = time.time() - start
return perf_time
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/middlewares.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Middleware methods for server."""

import time
from hmac import new
from http import HTTPStatus
Expand Down
3 changes: 2 additions & 1 deletion metadata_backend/api/operators/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base operator class shared by operators."""

from abc import ABC
from uuid import uuid4

Expand All @@ -16,7 +17,7 @@ class BaseOperator(ABC):
:param ABC: The abstract base class
"""

def __init__(self, db_client: AsyncIOMotorClient) -> None:
def __init__(self, db_client: AsyncIOMotorClient) -> None: # type: ignore
"""Init db_service.
:param db_client: Motor client used for database connections. Should be
Expand Down
1 change: 1 addition & 0 deletions metadata_backend/api/operators/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""File operator class."""

from dataclasses import dataclass
from datetime import datetime
from typing import Any, Optional
Expand Down
Loading

0 comments on commit 7141000

Please sign in to comment.