Skip to content
Snippets Groups Projects
Verified Commit 398f4a45 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

MAINT: Typing

parent 48728972
No related branches found
No related tags found
No related merge requests found
Pipeline #52180 failed
......@@ -35,11 +35,15 @@ install:
unittest:
pytest-3 unittests
lint:
pylint --unsafe-load-any-extension=y --fail-under=9.72 -d R,C --ignore=swagger_client src/caosadvancedtools
.PHONY: lint
typing:
mypy src unittests
mypy integrationtests
style:
pycodestyle --count --exclude=swagger_client src unittests
autopep8 -ar --diff --exit-code --exclude swagger_client src unittests
.PHONY: style
lint:
pylint --unsafe-load-any-extension=y --fail-under=9.72 -d R,C --ignore=swagger_client src/caosadvancedtools
.PHONY: lint
[pycodestyle]
ignore=E501,E121,E123,E126,E226,E24,E704,W503,W504
[mypy]
ignore_missing_imports = True
exclude = (?x)(
/extroot/ # Integration test data
)
\ No newline at end of file
......@@ -50,7 +50,7 @@ import matplotlib.pyplot as plt
import numpy as np
from caosadvancedtools.cfood import assure_property_is
from caosadvancedtools.crawler import apply_list_of_updates
from caosadvancedtools.guard import INSERT, UPDATE
from caosadvancedtools.guard import UPDATE
from caosadvancedtools.guard import global_guard as guard
from caosadvancedtools.serverside.helper import send_mail as main_send_mail
......@@ -62,7 +62,7 @@ logger = logging.getLogger(__name__)
guard.set_level(level=UPDATE)
def send_mail(changes: [db.Entity], receipient: str):
def send_mail(changes: list[db.Entity], receipient: str):
""" calls sendmail in order to send a mail to the curator about pending
changes
......
......@@ -24,6 +24,7 @@ from __future__ import annotations
import argparse
import json
from typing import Optional
import caosadvancedtools.json_schema_exporter as jsex
from caosadvancedtools.models import parser
......@@ -31,7 +32,7 @@ from caosadvancedtools.models import parser
def prepare_datamodel(modelfile, recordtypes: list[str], outfile: str,
do_not_create: list[str] = None):
do_not_create: Optional[list[str]] = None):
if do_not_create is None:
do_not_create = []
model = parser.parse_model_from_yaml(modelfile)
......
......@@ -24,6 +24,7 @@ import json
import os
import re
import tempfile
from typing import Optional
import jsonschema.exceptions as schema_exc
import pytest
......@@ -49,7 +50,7 @@ def rfp(*pathcomponents):
def fill_and_compare(json_file: str, template_file: str, known_good: str,
schema: str = None, custom_output: str = None):
schema: Optional[str] = None, custom_output: Optional[str] = None):
"""Fill the data into a template and compare to a known good.
Parameters:
......
......@@ -20,17 +20,15 @@
"""Testing the conversion from XLSX to JSON"""
from .utils import assert_equal_jsons
from caosadvancedtools.table_json_conversion import convert
import pytest
import datetime
import json
import os
import re
from types import SimpleNamespace
import pytest
from caosadvancedtools.table_json_conversion import convert
from .utils import assert_equal_jsons
from typing import Optional
def rfp(*pathcomponents):
......@@ -40,7 +38,7 @@ def rfp(*pathcomponents):
def convert_and_compare(xlsx_file: str, schema_file: str, known_good_file: str,
known_good_data: dict = None, strict: bool = False,
known_good_data: Optional[dict] = None, strict: bool = False,
validate: bool = True) -> dict:
"""Convert an XLSX file and compare to a known result.
......
......@@ -22,6 +22,7 @@
import json
import os
import tempfile
from typing import Optional
import pytest
from caosadvancedtools.table_json_conversion.table_generator import XLSXTemplateGenerator
......@@ -39,8 +40,9 @@ def rfp(*pathcomponents):
return os.path.join(os.path.dirname(__file__), *pathcomponents)
def _compare_generated_to_known_good(schema_file: str, known_good: str, foreign_keys: dict = None,
outfile: str = None) -> tuple:
def _compare_generated_to_known_good(schema_file: str, known_good: str,
foreign_keys: Optional[dict] = None,
outfile: Optional[str] = None) -> tuple:
"""Generate an XLSX from the schema, then compare to known good output.
Returns
......
......@@ -21,13 +21,13 @@
"""Utilities for the tests.
"""
from typing import Iterable, Union
from typing import Iterable, Optional, Union
from openpyxl import Workbook
def assert_equal_jsons(json1, json2, allow_none: bool = True, allow_empty: bool = True,
path: list = None) -> None:
path: Optional[list] = None) -> None:
"""Compare two json objects for near equality.
Raise an assertion exception if they are not equal."""
......@@ -100,7 +100,7 @@ hidden: bool, optional
)
def _is_recursively_none(obj: Union[list, dict] = None):
def _is_recursively_none(obj: Optional[Union[list, dict]] = None):
"""Test if ``obj`` is None or recursively consists only of None-like objects."""
if obj is None:
return True
......
......@@ -85,7 +85,7 @@ class SimpleCFood(AbstractFileCFood):
class DependendCFood(AbstractCFood):
existing = []
existing: list[DependendCFood] = []
@classmethod
def match_item(cls, item):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment