fix: linting

This commit is contained in:
Nicholas Tindle 2024-12-20 15:14:10 -06:00
parent e933502cbd
commit bef5637f29
No known key found for this signature in database
GPG Key ID: C4A2154D91363A47
4 changed files with 51 additions and 33 deletions

View File

@ -1,21 +1,19 @@
from datetime import datetime, timezone
from typing import Iterator
from typing import Iterator, Literal
from backend.util.settings import Settings
import praw
from pydantic import BaseModel
from pydantic import BaseModel, SecretStr
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import SchemaField, UserPasswordCredentials
from backend.util.mock import MockObject
from typing import Literal
from pydantic import SecretStr
from backend.data.model import CredentialsField, CredentialsMetaInput
from backend.data.model import (
CredentialsField,
CredentialsMetaInput,
SchemaField,
UserPasswordCredentials,
)
from backend.integrations.providers import ProviderName
from backend.util.mock import MockObject
from backend.util.settings import Settings
RedditCredentials = UserPasswordCredentials
RedditCredentialsInput = CredentialsMetaInput[

View File

@ -2,7 +2,7 @@ import logging
from typing import TYPE_CHECKING, Annotated, Literal
from fastapi import APIRouter, Body, Depends, HTTPException, Path, Query, Request
from pydantic import BaseModel, Field, SecretStr
from pydantic import BaseModel, Field
from backend.data.graph import set_node_webhook
from backend.data.integrations import (
@ -12,11 +12,9 @@ from backend.data.integrations import (
publish_webhook_event,
wait_for_webhook_event,
)
from backend.data.model import (
APIKeyCredentials,
Credentials,
CredentialsType,
OAuth2Credentials,
UserPasswordCredentials,
)
from backend.executor.manager import ExecutionManager

View File

@ -77,14 +77,14 @@ export const providerIcons: Record<
export type OAuthPopupResultMessage = { message_type: "oauth_popup_result" } & (
| {
success: true;
code: string;
state: string;
}
success: true;
code: string;
state: string;
}
| {
success: false;
message: string;
}
success: false;
message: string;
}
);
export const CredentialsInput: FC<{
@ -96,8 +96,10 @@ export const CredentialsInput: FC<{
const credentials = useCredentials();
const [isAPICredentialsModalOpen, setAPICredentialsModalOpen] =
useState(false);
const [isUserPasswordCredentialsModalOpen, setUserPasswordCredentialsModalOpen] =
useState(false);
const [
isUserPasswordCredentialsModalOpen,
setUserPasswordCredentialsModalOpen,
] = useState(false);
const [isOAuth2FlowInProgress, setOAuth2FlowInProgress] = useState(false);
const [oAuthPopupController, setOAuthPopupController] =
useState<AbortController | null>(null);
@ -182,7 +184,8 @@ export const CredentialsInput: FC<{
console.error("Error in OAuth callback:", error);
setOAuthError(
// type of error is unkown so we need to use String(error)
`Error in OAuth callback: ${error instanceof Error ? error.message : String(error)
`Error in OAuth callback: ${
error instanceof Error ? error.message : String(error)
}`,
);
} finally {
@ -549,7 +552,11 @@ export const UserPasswordCredentialsModal: FC<{
},
});
if (!credentials || credentials.isLoading || !credentials.supportsUserPassword) {
if (
!credentials ||
credentials.isLoading ||
!credentials.supportsUserPassword
) {
return null;
}
@ -590,7 +597,11 @@ export const UserPasswordCredentialsModal: FC<{
<FormItem>
<FormLabel>Username</FormLabel>
<FormControl>
<Input type="text" placeholder="Enter username..." {...field} />
<Input
type="text"
placeholder="Enter username..."
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
@ -603,7 +614,11 @@ export const UserPasswordCredentialsModal: FC<{
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input type="password" placeholder="Enter password..." {...field} />
<Input
type="password"
placeholder="Enter password..."
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
@ -616,7 +631,11 @@ export const UserPasswordCredentialsModal: FC<{
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input type="text" placeholder="Enter a name for this user password..." {...field} />
<Input
type="text"
placeholder="Enter a name for this user password..."
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>

View File

@ -116,9 +116,6 @@ export default function CredentialsProvider({
credentials,
];
} else if (credentials.type === "user_password") {
console.log("Adding user password credentials", credentials);
console.log("Updated provider", updatedProvider);
console.log("Updated provider savedUserPasswordCredentials", updatedProvider.savedUserPasswordCredentials);
updatedProvider.savedUserPasswordCredentials = [
...updatedProvider.savedUserPasswordCredentials,
credentials,
@ -297,7 +294,13 @@ export default function CredentialsProvider({
}));
});
});
}, [api, createAPIKeyCredentials, createUserPasswordCredentials, deleteCredentials, oAuthCallback]);
}, [
api,
createAPIKeyCredentials,
createUserPasswordCredentials,
deleteCredentials,
oAuthCallback,
]);
return (
<CredentialsProvidersContext.Provider value={providers}>