From 9ae5cd871573e78527b94e31768abbf617203b8c Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Fri, 22 Nov 2024 17:26:41 +0100
Subject: [PATCH] WIP: mypy

---
 .gitlab-ci.yml                 |  4 ++--
 setup.py                       | 24 ++++++++++++++++++++----
 src/linkahead/common/models.py |  9 ++++-----
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8845e407..e11ef9f6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -57,9 +57,9 @@ mypy:
   tags: [ docker ]
   stage: linting
   script:
-    - pip install mypy types-PyYAML types-jsonschema types-requests types-setuptools types-lxml types-python-dateutil pytest
+    - pip install .[mypy,test]
     - make mypy
-  allow_failure: true
+  # allow_failure: true
 
 # run unit tests
 unittest_py3.8:
diff --git a/setup.py b/setup.py
index 8b0f7ef0..ec20e88b 100755
--- a/setup.py
+++ b/setup.py
@@ -187,11 +187,27 @@ def setup_package():
                           'PyYAML>=5.4.1',
                           'future',
                           ],
-        extras_require={'keyring': ['keyring>=13.0.0'],
-                        'jsonschema': ['jsonschema>=4.4.0']},
+        extras_require={
+            'keyring': ['keyring>=13.0.0'],
+            'jsonschema': ['jsonschema>=4.4.0'],
+            "mypy": [
+                "mypy",
+                "types-PyYAML",
+                "types-jsonschema",
+                "types-requests",
+                "types-setuptools",
+                "types-lxml",
+                "types-python-dateutil",
+            ],
+            "test": [
+                "pytest",
+                "pytest-cov",
+                "coverage>=4.4.2",
+                "jsonschema>=4.4.0",
+            ]
+
+        },
         setup_requires=["pytest-runner>=2.0,<3dev"],
-        tests_require=["pytest", "pytest-cov", "coverage>=4.4.2",
-                       "jsonschema>=4.4.0"],
         package_data={
             'linkahead': ['py.typed', 'cert/indiscale.ca.crt', 'schema-pycaosdb-ini.yml'],
         },
diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py
index 6204e119..326e5f6d 100644
--- a/src/linkahead/common/models.py
+++ b/src/linkahead/common/models.py
@@ -41,7 +41,6 @@ import warnings
 from builtins import str
 from copy import deepcopy
 from datetime import date, datetime
-from enum import Enum
 from functools import cmp_to_key
 from hashlib import sha512
 from os import listdir
@@ -1120,7 +1119,7 @@ class Entity:
         else:
             return getattr(ref, special_selector.lower())
 
-    def get_property_values(self, *selectors):
+    def get_property_values(self, *selectors) -> tuple:
         """ Return a tuple with the values described by the given selectors.
 
         This represents an entity's properties as if it was a row of a table
@@ -2409,7 +2408,7 @@ class PropertyList(list):
     This class provides addional functionality like get/set_importance or get_by_name.
     """
 
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__()
         self._importance: dict[Entity, IMPORTANCE] = dict()
         self._inheritance: dict[Entity, INHERITANCE] = dict()
@@ -4544,7 +4543,7 @@ class ACL():
         return len(self._grants) + len(self._priority_grants) + \
             len(self._priority_denials) + len(self._denials) == 0
 
-    def clear(self):
+    def clear(self) -> None:
         self._grants: set[ACI] = set()
         self._denials: set[ACI] = set()
         self._priority_grants: set[ACI] = set()
@@ -5148,7 +5147,7 @@ class Info():
 
     """
 
-    def __init__(self):
+    def __init__(self) -> None:
         self.messages = Messages()
         self.user_info: Optional[UserInfo] = None
         self.time_zone: Optional[TimeZone] = None
-- 
GitLab