From 21bde76d92a957bdc775f7f6314366cde332e3cc Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Fri, 10 May 2024 11:42:47 +0200 Subject: [PATCH] Tweak mypy configuration --- lms/services/application_instance.py | 2 +- lms/services/lti_role_service.py | 4 ++-- lms/services/lti_user.py | 3 +-- lms/views/admin/_schemas.py | 2 +- pyproject.toml | 4 ++++ 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lms/services/application_instance.py b/lms/services/application_instance.py index 47f302002f..271ba4d8e8 100644 --- a/lms/services/application_instance.py +++ b/lms/services/application_instance.py @@ -318,7 +318,7 @@ def create_application_instance( # pylint:disable=too-many-arguments "Hypothesis" + secrets.token_hex(16) if not deployment_id else None ) - application_instance = ApplicationInstance( # type: ignore + application_instance = ApplicationInstance( name=name, consumer_key=consumer_key, shared_secret=secrets.token_hex(32), diff --git a/lms/services/lti_role_service.py b/lms/services/lti_role_service.py index 3f70fd2c09..6433c84be6 100644 --- a/lms/services/lti_role_service.py +++ b/lms/services/lti_role_service.py @@ -31,7 +31,7 @@ def get_roles(self, role_description: str) -> list[LTIRole]: role.update_from_value() if missing := (set(role_strings) - set(role.value for role in roles)): - new_roles = [LTIRole(value=value) for value in missing] # type: ignore + new_roles = [LTIRole(value=value) for value in missing] self._db.add_all(new_roles) roles.extend(new_roles) @@ -43,7 +43,7 @@ def get_roles_for_application_instance( ) -> list[Role]: self._db.flush() # Make sure roles have IDs # pylint:disable=no-member - overrides = self._db.execute( # type: ignore + overrides = self._db.execute( select( LTIRole.value.label("value"), func.coalesce(LTIRoleOverride.type, LTIRole.type).label("type"), diff --git a/lms/services/lti_user.py b/lms/services/lti_user.py index e7d058682f..04537b4a4b 100644 --- a/lms/services/lti_user.py +++ b/lms/services/lti_user.py @@ -63,9 +63,8 @@ def serialize(lti_user: LTIUser) -> dict: }, } - def deserialize(self, **kwargs: dict) -> LTIUser: # type: ignore + def deserialize(self, **kwargs: dict) -> LTIUser: """Create an LTIUser based on kwargs.""" - # type: ignore application_instance = self._application_instance_service.get_for_launch( kwargs["application_instance_id"] # type: ignore ) diff --git a/lms/views/admin/_schemas.py b/lms/views/admin/_schemas.py index d5e1a706ae..7b387d2440 100644 --- a/lms/views/admin/_schemas.py +++ b/lms/views/admin/_schemas.py @@ -19,7 +19,7 @@ def deserialize(self, value, attr, data, **kwargs): # pylint:disable=compare-to-empty-string if value == missing or value.strip() == "": return None - return super().deserialize(value, attr, data, **kwargs) # type: ignore + return super().deserialize(value, attr, data, **kwargs) class EmptyStringInt(EmptyStringNoneMixin, fields.Int): # type: ignore diff --git a/pyproject.toml b/pyproject.toml index 88b2cfae29..423e485f01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -161,6 +161,10 @@ project_type = "application" [tool.mypy] python_version = 3.11 +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true + disable_error_code = [ "import-untyped",