Skip to content

Commit

Permalink
chore: mypy: disallow untyped definitions (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Mar 27, 2024
1 parent 1ecb1ea commit 62b2fff
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/models/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create(
)

@model_validator(mode="after")
def check_group_occurs_only_once(self):
def check_group_occurs_only_once(self) -> PermissionScope:
all_groups = []
for field in self.model_fields:
all_groups.extend(getattr(self, field))
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ line-length = 120

[tool.isort]
profile = "black"

[tool.mypy]
ignore_missing_imports = false
show_column_numbers = true
strict = true
disallow_untyped_defs = true
8 changes: 4 additions & 4 deletions tests/test_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ class TestAp(unittest.TestCase):
iri="http://rdfh.ch/foo",
)

def test_add_permission(self):
def test_add_permission(self) -> None:
self.ap.add_permission(ApValue.ProjectAdminRightsAllPermission)
self.assertIn(ApValue.ProjectAdminRightsAllPermission, self.ap.hasPermissions)

def test_add_permission_already_exists(self):
def test_add_permission_already_exists(self) -> None:
with self.assertRaises(ValueError):
self.ap.add_permission(ApValue.ProjectAdminGroupAllPermission)

def test_remove_permission(self):
def test_remove_permission(self) -> None:
self.ap.remove_permission(ApValue.ProjectAdminGroupAllPermission)
self.assertNotIn(ApValue.ProjectAdminGroupAllPermission, self.ap.hasPermissions)

def test_remove_permission_not_exists(self):
def test_remove_permission_not_exists(self) -> None:
with self.assertRaises(ValueError):
self.ap.remove_permission(ApValue.ProjectAdminAllPermission)
4 changes: 2 additions & 2 deletions tests/test_ap_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tearDown(self) -> None:
if self.output_dir.is_dir():
shutil.rmtree(self.output_dir)

def test_serialize_aps_of_project(self):
def test_serialize_aps_of_project(self) -> None:
serialize_aps_of_project(
project_aps=[self.ap1, self.ap2],
shortcode=self.shortcode,
Expand All @@ -55,7 +55,7 @@ def test_serialize_aps_of_project(self):
self.assertEqual(self.ap1, Ap.model_validate(aps_as_dicts[0]))
self.assertEqual(self.ap2, Ap.model_validate(aps_as_dicts[1]))

def test_deserialize_aps_of_project(self):
def test_deserialize_aps_of_project(self) -> None:
shutil.copy(src=self.testdata_file, dst=self.output_file)
aps = deserialize_aps_of_project(
shortcode=self.shortcode,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_doap_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def tearDown(self) -> None:
if testdata_dir.is_dir():
shutil.rmtree(testdata_dir)

def test_doap_serialization(self):
def test_doap_serialization(self) -> None:
doap1 = Doap(
target=DoapTarget(
project="http://rdfh.ch/projects/MsOaiQkcQ7-QPxsYBKckfQ",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_oap_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def tearDown(self) -> None:
if testdata_dir.is_dir():
shutil.rmtree(testdata_dir)

def test_oap_serialization(self):
def test_oap_serialization(self) -> None:
oap1 = Oap(
scope=PermissionScope.create(
CR=[builtin_groups.PROJECT_ADMIN],
Expand Down

0 comments on commit 62b2fff

Please sign in to comment.