Skip to content

Commit 4eafd0d

Browse files
chrisburrweb-flow
authored andcommitted
sweep: #6442 Add mypy CI job
1 parent 5c453b3 commit 4eafd0d

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

.github/workflows/basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
# DISET's string and unicode types being poorly defined
7272
- pytest --runslow -k 'not test_BaseType_Unicode and not test_nestedStructure'
7373
- pylint -E src/
74+
- mypy
7475

7576
steps:
7677
- uses: actions/checkout@v2

environment.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,20 @@ dependencies:
9191
- typing >=3.6.6
9292
- pyyaml
9393
- rucio-clients
94+
# For mypy
95+
- mypy >=0.982
96+
- types-cachetools
97+
- types-python-dateutil
98+
- types-pytz
99+
- types-PyYAML
100+
- types-requests
101+
- types-setuptools
94102
- pip:
95103
# Prerelease of the required package for integration of OAuth2
96104
- Authlib>=1.0.0.a2
97105
- dominate
98106
- pyjwt
99107
# This is a fork of tornado with a patch to allow for configurable iostream
100-
# It should eventually be part of DIRACGrid
101108
- git+https://github.com/DIRACGrid/tornado.git@iostreamConfigurable
102109
# This is an extension of Tornado to use M2Crypto
103110
# It should eventually be part of DIRACGrid

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ allow_redefinition = true
2121
strict = true
2222
check_untyped_defs = true
2323
ignore_missing_imports = true
24+
files = [
25+
'src/DIRAC/Core/Utilities/ReturnValues.py',
26+
'src/DIRAC/Core/Security/Properties.py'
27+
]
2428
exclude = [
2529
'/tests/'
2630
]

src/DIRAC/Core/Security/Properties.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import operator
77
from enum import Enum
8-
from typing import Union
8+
from typing import Callable, Union
99

1010

1111
class SecurityProperty(str, Enum):
@@ -94,7 +94,7 @@ def __str__(self) -> str:
9494
def __repr__(self) -> str:
9595
return repr(self.property)
9696

97-
def __call__(self, allowed_properties: list[SecurityProperty]):
97+
def __call__(self, allowed_properties: list[SecurityProperty]) -> bool:
9898
return self.property in allowed_properties
9999

100100
def __and__(self, value: UnevaluatedProperty) -> UnevaluatedExpression:
@@ -111,7 +111,7 @@ def __invert__(self) -> UnevaluatedExpression:
111111

112112

113113
class UnevaluatedExpression(UnevaluatedProperty):
114-
def __init__(self, operator: callable, *args: list[UnevaluatedProperty]):
114+
def __init__(self, operator: Callable[..., bool], *args: UnevaluatedProperty):
115115
self.operator = operator
116116
self.args = args
117117

@@ -128,7 +128,7 @@ def __str__(self) -> str:
128128
def __repr__(self) -> str:
129129
return f"{self.operator.__name__}({', '.join(map(repr, self.args))})"
130130

131-
def __call__(self, properties):
131+
def __call__(self, properties: list[SecurityProperty]) -> bool:
132132
return self.operator(*(a(properties) for a in self.args))
133133

134134

0 commit comments

Comments
 (0)