Skip to content

Commit

Permalink
fix(typing): Accommodate for optional untyped imports
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Mar 7, 2025
1 parent 2a8900c commit 2d9271f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion api/api_keys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def delete_role_api_keys( # type: ignore[no-untyped-def]
self,
):
if settings.IS_RBAC_INSTALLED:
from rbac.models import MasterAPIKeyRole # type: ignore[import-not-found]
from rbac.models import ( # type: ignore[import-not-found,unused-ignore]
MasterAPIKeyRole,
)

MasterAPIKeyRole.objects.filter(master_api_key=self.id).delete()
2 changes: 1 addition & 1 deletion api/organisations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@


if settings.IS_RBAC_INSTALLED:
from rbac.views import ( # type: ignore[import-not-found]
from rbac.views import ( # type: ignore[import-not-found,unused-ignore]
GroupRoleViewSet,
MasterAPIKeyRoleViewSet,
RoleEnvironmentPermissionsViewSet,
Expand Down
4 changes: 2 additions & 2 deletions api/permissions/rbac_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from projects.models import Project

if settings.IS_RBAC_INSTALLED: # pragma: no cover
from rbac.permission_service import ( # type: ignore[import-not-found]
from rbac.permission_service import ( # type: ignore[import-not-found,unused-ignore]
get_role_permission_filter,
)
from rbac.permissions_calculator import ( # type: ignore[import-not-found]
from rbac.permissions_calculator import ( # type: ignore[import-not-found,unused-ignore]
RolePermissionData,
get_roles_permission_data_for_environment,
get_roles_permission_data_for_organisation,
Expand Down
14 changes: 11 additions & 3 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ ignore = []

[tool.ruff.lint.per-file-ignores]
# Need the * prefix to work with pre-commit which runs from the root of the repo
"*app/settings/local.py"= ["F403", "F405"]
"*app/settings/production.py"= ["F403", "F405"]
"*app/settings/saas.py"= ["F403", "F405"]
"*app/settings/local.py" = ["F403", "F405"]
"*app/settings/production.py" = ["F403", "F405"]
"*app/settings/saas.py" = ["F403", "F405"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
Expand Down Expand Up @@ -77,6 +77,14 @@ strict = true
module = ["admin_sso.models"]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["rbac.*"]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["saml.*"]
ignore_missing_imports = true

[tool.django-stubs]
django_settings_module = "app.settings.local"

Expand Down

0 comments on commit 2d9271f

Please sign in to comment.