Skip to content

Commit

Permalink
fix: make mypy ignore comments more specific
Browse files Browse the repository at this point in the history
This avoids missing other types of error.
  • Loading branch information
sgaist committed Sep 19, 2024
1 parent c32b861 commit 6464211
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ async def main_container(server: "UserServer") -> client.V1Container | None:
name=f"{prefix}ANONYMOUS_SESSION",
value="false" if server.user.is_authenticated else "true",
),
client.V1EnvVar(name=f"{prefix}RENKU_ACCESS_TOKEN", value=str(server.user.access_token)), # type: ignore
client.V1EnvVar(name=f"{prefix}RENKU_REFRESH_TOKEN", value=str(server.user.refresh_token)), # type: ignore
client.V1EnvVar(name=f"{prefix}RENKU_ACCESS_TOKEN", value=str(server.user.access_token)), # type: ignore[operator]
client.V1EnvVar(name=f"{prefix}RENKU_REFRESH_TOKEN", value=str(server.user.refresh_token)), # type: ignore[operator]
client.V1EnvVar(name=f"{prefix}RENKU_REALM", value=server.config.keycloak_realm),
client.V1EnvVar(
name=f"{prefix}RENKU_CLIENT_ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
},
{
"name": f"{prefix}USER__USERNAME",
"value": server.user.email, # type: ignore
"value": server.user.email, # type: ignore[operator]
},
{
"name": f"{prefix}USER__RENKU_TOKEN",
"value": str(server.user.access_token), # type: ignore
"value": str(server.user.access_token), # type: ignore[operator]
},
{"name": f"{prefix}IS_GIT_PROXY_ENABLED", "value": "0" if user_is_anonymous else "1"},
{
Expand Down Expand Up @@ -82,27 +82,27 @@ async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
},
]
if server.user.is_authenticated:
if server.user.email: # type: ignore
if server.user.email: # type: ignore[operator]
env.append(
{"name": f"{prefix}USER__EMAIL", "value": server.user.email}, # type: ignore
{"name": f"{prefix}USER__EMAIL", "value": server.user.email}, # type: ignore[operator]
)
if server.user.full_name: # type: ignore
if server.user.full_name: # type: ignore[operator]
env.append(
{
"name": f"{prefix}USER__FULL_NAME",
"value": server.user.full_name, # type: ignore
"value": server.user.full_name, # type: ignore[operator]
},
)
elif server.user.first_name or server.user.last_name: # type: ignore
full_name = server.user.first_name or "" # type: ignore
elif server.user.first_name or server.user.last_name: # type: ignore[operator]
full_name = server.user.first_name or "" # type: ignore[operator]
if full_name == "":
full_name = server.user.last_name or "" # type: ignore
full_name = server.user.last_name or "" # type: ignore[operator]
else:
full_name += " " + (server.user.last_name or "") # type: ignore
full_name += " " + (server.user.last_name or "") # type: ignore[operator]
env.append(
{
"name": f"{prefix}USER__FULL_NAME",
"value": server.user.full_name, # type: ignore
"value": server.user.full_name, # type: ignore[operator]
},
)

Expand Down Expand Up @@ -185,11 +185,11 @@ async def git_clone_container(server: "UserServer") -> dict[str, Any] | None:
},
{
"name": f"{prefix}USER__USERNAME",
"value": server.user.email, # type: ignore
"value": server.user.email, # type: ignore[operator]
},
{
"name": f"{prefix}USER__RENKU_TOKEN",
"value": str(server.user.access_token), # type: ignore
"value": str(server.user.access_token), # type: ignore[operator]
},
{"name": f"{prefix}IS_GIT_PROXY_ENABLED", "value": "0" if user_is_anonymous else "1"},
{
Expand Down Expand Up @@ -219,27 +219,27 @@ async def git_clone_container(server: "UserServer") -> dict[str, Any] | None:
},
]
if server.user.is_authenticated:
if server.user.email: # type: ignore
if server.user.email: # type: ignore[operator]
env.append(
{"name": f"{prefix}USER__EMAIL", "value": server.user.email}, # type: ignore
{"name": f"{prefix}USER__EMAIL", "value": server.user.email}, # type: ignore[operator]
)
if server.user.full_name: # type: ignore
if server.user.full_name: # type: ignore[operator]
env.append(
{
"name": f"{prefix}USER__FULL_NAME",
"value": server.user.full_name, # type: ignore
"value": server.user.full_name, # type: ignore[operator]
},
)
elif server.user.first_name or server.user.last_name: # type: ignore
full_name = server.user.first_name or "" # type: ignore
elif server.user.first_name or server.user.last_name: # type: ignore[operator]
full_name = server.user.first_name or "" # type: ignore[operator]
if full_name == "":
full_name = server.user.last_name or "" # type: ignore
full_name = server.user.last_name or "" # type: ignore[operator]
else:
full_name += " " + (server.user.last_name or "") # type: ignore
full_name += " " + (server.user.last_name or "") # type: ignore[operator]
env.append(
{
"name": f"{prefix}USER__FULL_NAME",
"value": server.user.full_name, # type: ignore
"value": server.user.full_name, # type: ignore[operator]
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def user_secrets(server: "UserServer") -> list[dict[str, Any]]:
image=server.config.user_secrets.image,
env=[
client.V1EnvVar(name="DATA_SERVICE_URL", value=server.config.data_service_url),
client.V1EnvVar(name="RENKU_ACCESS_TOKEN", value=str(server.user.access_token)), # type: ignore
client.V1EnvVar(name="RENKU_ACCESS_TOKEN", value=str(server.user.access_token)), # type: ignore[operator]
client.V1EnvVar(name="ENCRYPTED_SECRETS_MOUNT_PATH", value="/encrypted"),
client.V1EnvVar(name="DECRYPTED_SECRETS_MOUNT_PATH", value="/decrypted"),
],
Expand Down
2 changes: 1 addition & 1 deletion components/renku_data_services/notebooks/blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ async def launch_notebook_helper(
"secret_ids": [str(id_) for id_ in k8s_user_secret.user_secret_ids],
"owner_references": [owner_reference],
}
headers = {"Authorization": f"bearer {user.access_token}"} # type: ignore
headers = {"Authorization": f"bearer {user.access_token}"} # type: ignore[operator]

async def _on_error(server_name: str, error_msg: str) -> None:
await nb_config.k8s_client.delete_server(server_name, safe_username=user.id)
Expand Down

0 comments on commit 6464211

Please sign in to comment.