Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
fix: type annotations
  • Loading branch information
terjesyl committed Jan 29, 2024
1 parent 9c06da5 commit bd089a7
Show file tree
Hide file tree
Showing 47 changed files with 350 additions and 333 deletions.
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import tempfile

import nox
Expand Down
612 changes: 291 additions & 321 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ aiohttp-middlewares = "^2.2.0"

[tool.poetry.dev-dependencies]
asynctest = "^0.13.0"
pytest = "^7.4.3"
coverage = {extras = ["toml"], version = "^7.3.2"}
pytest-asyncio = "^0.21.1"
pytest = "^7.4.4"
coverage = {extras = ["toml"], version = "^7.4.1"}
pytest-asyncio = "^0.23.3"
pytest-dotenv = "^0.5.2"
pytest-docker = "^2.0.1"
pytest-cov = "^4.1.0"
black = "^23.11.0"
black = "^24.1.1"
flake8 = "^6.1.0"
flake8-bandit = "^4.1.1"
flake8-black = "^0.3.6"
Expand All @@ -39,7 +39,7 @@ flake8-docstrings = "^1.7.0"
flake8-import-order = "^0.18.2"
pep8-naming = "^0.13.3"
safety = "^2.3.5"
mypy = "1.6.1"
mypy = "1.8.0"
flake8-annotations = "^3.0.1"
codecov = "^2.1.13"
requests-mock = "^1.11.0"
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Package with backend-for-frontend service that provides content for fdk portal's organization pages."""

from aiohttp import web

from fdk_organization_bff.app import create_app
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for starting an aiohttp API."""

import logging

from aiohttp import web
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
organization_concepts
organization_informationmodels
"""

from fdk_organization_bff.classes.catalog_quality_score import CatalogQualityScore
from fdk_organization_bff.classes.filter_enum import FilterEnum
from fdk_organization_bff.classes.organization_catalog import OrganizationCatalog
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/catalog_quality_score.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Catalog quality rating data class."""

from dataclasses import dataclass
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/filter_enum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Filter enum class."""

from enum import Enum


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/organization_catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization catalog data class."""

from dataclasses import dataclass
from typing import Optional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization catalog list data class."""

from dataclasses import dataclass
from typing import List

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization catalog summary data class."""

from dataclasses import dataclass
from typing import Dict

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/organization_category.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization category data classes."""

from dataclasses import dataclass
from typing import List

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/organization_concepts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization concepts data class."""

from dataclasses import dataclass


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization datasets data class."""

from dataclasses import dataclass


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/organization_datasets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization datasets data class."""

from dataclasses import dataclass
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/classes/organization_details.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization details data class."""

from dataclasses import dataclass
from typing import Dict, Optional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Organization informationmodel data class."""

from dataclasses import dataclass


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
Modules:
config
"""

from .config import Config
1 change: 1 addition & 0 deletions src/fdk_organization_bff/config/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configure fdk-organization-bff."""

import os
from typing import Dict, Type, TypeVar

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Gunicorn module."""

import logging
import multiprocessing
from os import environ as env
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
state_categories
municipality_categories
"""

from .municipality_categories import MunicipalityCategories
from .org_catalog import OrgCatalog
from .org_catalogs import OrgCatalogs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Resource module for municipality categories."""

from dataclasses import asdict
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/resources/org_catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Resource module for specific organization catalog."""

from dataclasses import asdict

from aiohttp.web import json_response, Response, View
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/resources/org_catalogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Resource module for specific organization catalog."""

from dataclasses import asdict
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/resources/ping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Resource module for ping."""

from aiohttp.web import Response, View


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/resources/ready.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Resource module for ready."""

from aiohttp.web import Response, View


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/resources/state_categories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Resource module for state categories."""

from dataclasses import asdict
from typing import Optional

Expand Down
1 change: 0 additions & 1 deletion src/fdk_organization_bff/resources/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Utils module for http resources."""


fifteen_min_cache_header = {
"Cache-Control": "no-cache, no-store, max-age=900, must-revalidate"
}
1 change: 1 addition & 0 deletions src/fdk_organization_bff/service/adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Adapter layer module for fdk-organization-bff."""

from typing import Dict, List, Optional, Union

from aiohttp import ClientSession
Expand Down
9 changes: 6 additions & 3 deletions src/fdk_organization_bff/service/org_catalog_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Service layer module for fdk-organization-bff."""

import asyncio
import logging
from typing import cast, Dict, List, Optional
from typing import cast, Dict, List, Optional, Union

from aiohttp import ClientSession

Expand Down Expand Up @@ -282,6 +283,8 @@ async def get_municipality_categories(
async def fetch_municipality_data() -> Dict:
"""Return map of municipality numbers to connected organization number."""
async with ClientSession() as session:
fylke: Union[Dict, BaseException]
kommune: Union[Dict, BaseException]
(
fylke,
kommune,
Expand All @@ -297,10 +300,10 @@ async def fetch_municipality_data() -> Dict:

if isinstance(fylke, BaseException):
logging.warning("Unable to fetch fylke data from reference data")
fylke = []
fylke = dict()

Check warning on line 303 in src/fdk_organization_bff/service/org_catalog_service.py

View check run for this annotation

Codecov / codecov/patch

src/fdk_organization_bff/service/org_catalog_service.py#L303

Added line #L303 was not covered by tests
if isinstance(kommune, BaseException):
logging.warning("Unable to fetch kommune data from reference data")
kommune = []
kommune = dict()

Check warning on line 306 in src/fdk_organization_bff/service/org_catalog_service.py

View check run for this annotation

Codecov / codecov/patch

src/fdk_organization_bff/service/org_catalog_service.py#L306

Added line #L306 was not covered by tests

return {
"fylke": fylke.get("fylkeOrganisasjoner"),
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/sparql/concept_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for Concept SPARQL-queries."""

from string import Template


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/sparql/dataservice_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for DataService SPARQL-queries."""

from string import Template


Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/sparql/dataset_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for Dataset SPARQL-queries."""

from string import Template


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for Information Model SPARQL-queries."""

from string import Template


Expand Down
9 changes: 6 additions & 3 deletions src/fdk_organization_bff/utils/mappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Mapper module."""

import logging
import traceback
from typing import Dict, List, Optional
Expand Down Expand Up @@ -43,9 +44,11 @@ def map_catalog_quality_score(
if score and max_score:
return CatalogQualityScore(
score=score,
percentage=int(round(100 * (int(score) / int(max_score))))
if score and max_score
else None,
percentage=(
int(round(100 * (int(score) / int(max_score))))
if score and max_score
else None
),
)

return None
Expand Down
1 change: 1 addition & 0 deletions src/fdk_organization_bff/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Util module."""

import datetime
import logging
import traceback
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conftest module."""

from asyncio import AbstractEventLoop
import datetime
import os
Expand Down
1 change: 1 addition & 0 deletions tests/contract/test_api_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contract test cases for ping & ready."""

import pytest
import requests

Expand Down
1 change: 1 addition & 0 deletions tests/contract/test_get_all_catalogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contract test cases for cases for all organization catalogs."""

import json

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/contract/test_get_specific_catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contract test cases for specific organization catalogs."""

import json

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_api_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Integration test cases for ping & ready routes."""

from aiohttp.test_utils import TestClient
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_get_all_catalogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Integration test cases for all organization catalogs."""

import json

from aiohttp.test_utils import TestClient
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_get_categories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Integration test cases for organization categories."""

from aiohttp.test_utils import TestClient
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_get_specific_catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Integration test cases for specific organizations."""

import json
from unittest.mock import Mock

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_mappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit test cases for mappers."""

import pytest

from fdk_organization_bff.classes import CatalogQualityScore
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit test cases for service."""

import asyncio
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit test cases for utils."""

import pytest

from fdk_organization_bff.utils.utils import resource_is_new, url_with_params
Expand Down

0 comments on commit bd089a7

Please sign in to comment.