From 05c3838208ae4199e9ed468e9a086550840f47f0 Mon Sep 17 00:00:00 2001 From: Michael Landis Date: Fri, 27 Sep 2024 13:30:52 -0700 Subject: [PATCH 1/2] fix: lint errors on 3.10+ for auth protos Adds per-line ignores for generated auth protobuf. --- src/momento/internal/_utilities/_permissions.py | 2 +- tests/momento/auth_client/test_permissions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/momento/internal/_utilities/_permissions.py b/src/momento/internal/_utilities/_permissions.py index d446c38b..4f33394e 100644 --- a/src/momento/internal/_utilities/_permissions.py +++ b/src/momento/internal/_utilities/_permissions.py @@ -34,7 +34,7 @@ class SuperuserPermissions(PredefinedScope): def permissions_from_permission_scope(scope: PermissionScope) -> permissions_pb.Permissions: if isinstance(scope.permission_scope, SuperuserPermissions): - return permissions_pb.Permissions(super_user=permissions_pb.SuperUserPermissions.SuperUser) + return permissions_pb.Permissions(super_user=permissions_pb.SuperUserPermissions.SuperUser) # type: ignore[attr-defined,misc] elif isinstance(scope.permission_scope, Permissions) and not isinstance(scope.permission_scope, PredefinedScope): converted_perms = [ token_permission_to_grpc_permission(permission) for permission in scope.permission_scope.permissions diff --git a/tests/momento/auth_client/test_permissions.py b/tests/momento/auth_client/test_permissions.py index 49a5ae54..714b8ecc 100644 --- a/tests/momento/auth_client/test_permissions.py +++ b/tests/momento/auth_client/test_permissions.py @@ -30,7 +30,7 @@ def test_creates_expected_grpc_permissions_for_internal_superuser_permissions() -> None: - expected_permission = permissions_pb.Permissions(super_user=permissions_pb.SuperUserPermissions.SuperUser) + expected_permission = permissions_pb.Permissions(super_user=permissions_pb.SuperUserPermissions.SuperUser) # type: ignore[attr-defined] constructed_permission = permissions_from_permission_scope(PermissionScope(SuperuserPermissions())) assert expected_permission == constructed_permission From a438d9921b9d5047937ed687937258216b002229 Mon Sep 17 00:00:00 2001 From: Michael Landis Date: Fri, 27 Sep 2024 13:42:09 -0700 Subject: [PATCH 2/2] fix: ignore in pyproject.toml in order to be cross version compat We have to ignore in mypy instead of in the source because of version differences between 3.7 and 3.7+. --- pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index bbeda049..61bf95d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,12 +116,20 @@ disallow_any_expr = false module = "momento.internal._utilities._momento_version" ignore_errors = true +[[tool.mypy.overrides]] +# reading an enum in a protobuf generated class +module = "momento.internal._utilities._permissions" +ignore_errors = true + [[tool.mypy.overrides]] module = "tests.*" disallow_any_expr = false disallow_any_decorated = false disallow_untyped_decorators = false +[[tool.mypy.overrides]] +module = "tests.momento.auth_client.test_permissions" +ignore_errors = true [tool.ruff] select = [