chore: fix indention violations by applying E111 to E117 ruff rules (#4925)

This commit is contained in:
Bowen Liang 2024-06-05 14:05:15 +08:00 committed by GitHub
parent 6b6afb7708
commit f32b440c4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 73 additions and 61 deletions

View File

@ -36,7 +36,7 @@ jobs:
- name: Ruff check - name: Ruff check
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
run: ruff check ./api run: ruff check --preview ./api
- name: Dotenv check - name: Dotenv check
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'

View File

@ -528,4 +528,3 @@ class BaseAgentRunner(AppRunner):
return UserPromptMessage(content=prompt_message_contents) return UserPromptMessage(content=prompt_message_contents)
else: else:
return UserPromptMessage(content=message.query) return UserPromptMessage(content=message.query)

View File

@ -54,7 +54,7 @@ class PGVectoRS(BaseVector):
class _Table(CollectionORM): class _Table(CollectionORM):
__tablename__ = collection_name __tablename__ = collection_name
__table_args__ = {"extend_existing": True} # noqa: RUF012 __table_args__ = {"extend_existing": True}
id: Mapped[UUID] = mapped_column( id: Mapped[UUID] = mapped_column(
postgresql.UUID(as_uuid=True), postgresql.UUID(as_uuid=True),
primary_key=True, primary_key=True,

View File

@ -190,7 +190,7 @@ class RelytVector(BaseVector):
conn.execute(chunks_table.delete().where(delete_condition)) conn.execute(chunks_table.delete().where(delete_condition))
return True return True
except Exception as e: except Exception as e:
print("Delete operation failed:", str(e)) # noqa: T201 print("Delete operation failed:", str(e))
return False return False
def delete_by_metadata_field(self, key: str, value: str): def delete_by_metadata_field(self, key: str, value: str):

View File

@ -50,7 +50,7 @@ class BaseDocumentTransformer(ABC):
) -> Sequence[Document]: ) -> Sequence[Document]:
raise NotImplementedError raise NotImplementedError
""" # noqa: E501 """
@abstractmethod @abstractmethod
def transform_documents( def transform_documents(

View File

@ -68,7 +68,7 @@ class ArxivAPIWrapper(BaseModel):
Args: Args:
query: a plaintext search query query: a plaintext search query
""" # noqa: E501 """
try: try:
results = self.arxiv_search( # type: ignore results = self.arxiv_search( # type: ignore
query[: self.ARXIV_MAX_QUERY_LENGTH], max_results=self.top_k_results query[: self.ARXIV_MAX_QUERY_LENGTH], max_results=self.top_k_results

View File

@ -121,4 +121,5 @@ class SearXNGSearchTool(BuiltinTool):
query=query, query=query,
search_type=search_type, search_type=search_type,
result_type=result_type, result_type=result_type,
topK=num_results) topK=num_results
)

View File

@ -30,7 +30,7 @@ class TwilioAPIWrapper(BaseModel):
Twilio also work here. You cannot, for example, spoof messages from a private Twilio also work here. You cannot, for example, spoof messages from a private
cell phone number. If you are using `messaging_service_sid`, this parameter cell phone number. If you are using `messaging_service_sid`, this parameter
must be empty. must be empty.
""" # noqa: E501 """
@validator("client", pre=True, always=True) @validator("client", pre=True, always=True)
def set_validator(cls, values: dict) -> dict: def set_validator(cls, values: dict) -> dict:
@ -60,7 +60,7 @@ class TwilioAPIWrapper(BaseModel):
SMS/MMS or SMS/MMS or
[Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses) [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses)
for other 3rd-party channels. for other 3rd-party channels.
""" # noqa: E501 """
message = self.client.messages.create(to, from_=self.from_number, body=body) message = self.client.messages.create(to, from_=self.from_number, body=body)
return message.sid return message.sid

View File

@ -332,7 +332,8 @@ class Tool(BaseModel, ABC):
:param text: the text :param text: the text
:return: the text message :return: the text message
""" """
return ToolInvokeMessage(type=ToolInvokeMessage.MessageType.TEXT, return ToolInvokeMessage(
type=ToolInvokeMessage.MessageType.TEXT,
message=text, message=text,
save_as=save_as save_as=save_as
) )
@ -344,7 +345,8 @@ class Tool(BaseModel, ABC):
:param blob: the blob :param blob: the blob
:return: the blob message :return: the blob message
""" """
return ToolInvokeMessage(type=ToolInvokeMessage.MessageType.BLOB, return ToolInvokeMessage(
type=ToolInvokeMessage.MessageType.BLOB,
message=blob, meta=meta, message=blob, meta=meta,
save_as=save_as save_as=save_as
) )

View File

@ -13,8 +13,18 @@ select = [
"F", # pyflakes rules "F", # pyflakes rules
"I", # isort rules "I", # isort rules
"UP", # pyupgrade rules "UP", # pyupgrade rules
"E101", # mixed-spaces-and-tabs
"E111", # indentation-with-invalid-multiple
"E112", # no-indented-block
"E113", # unexpected-indentation
"E115", # no-indented-block-comment
"E116", # unexpected-indentation-comment
"E117", # over-indented
"RUF019", # unnecessary-key-check "RUF019", # unnecessary-key-check
"RUF100", # unused-noqa
"RUF101", # redirected-noqa
"S506", # unsafe-yaml-load "S506", # unsafe-yaml-load
"W191", # tab-indentation
"W605", # invalid-escape-sequence "W605", # invalid-escape-sequence
] ]
ignore = [ ignore = [

View File

@ -9,7 +9,7 @@ if ! command -v ruff &> /dev/null; then
fi fi
# run ruff linter # run ruff linter
ruff check --fix ./api ruff check --fix --preview ./api
# env files linting relies on `dotenv-linter` in path # env files linting relies on `dotenv-linter` in path
if ! command -v dotenv-linter &> /dev/null; then if ! command -v dotenv-linter &> /dev/null; then

View File

@ -31,7 +31,7 @@ if $api_modified; then
pip install ruff pip install ruff
fi fi
ruff check ./api || status=$? ruff check --preview ./api || status=$?
status=${status:-0} status=${status:-0}