-
Notifications
You must be signed in to change notification settings - Fork 8
version to 1.1.0 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version to 1.1.0 #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ wheels/ | |
.env.dora | ||
.env.kodo | ||
|
||
mcp_server/test.py | ||
src/mcp_server/test.py |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# v1.1.0 | ||
- 支持 Bucket 为空 | ||
|
||
# v1.0.0 | ||
|
||
- 支持 Kodo 服务 | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,6 @@ def load_config() -> Config: | |
logger.error("QINIU_REGION_NAME is not configured") | ||
raise ValueError("QINIU_REGION_NAME is not configured") | ||
|
||
if not config.buckets: | ||
logger.error("QINIU_BUCKETS is not configured") | ||
raise ValueError("QINIU_BUCKETS is not configured") | ||
|
||
logger.info(f"Configured access_key: {config.access_key}") | ||
logger.info(f"Configured endpoint_url: {config.endpoint_url}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use lazy % formatting in logging functions (logging-fstring-interpolation) Detailslint 解释
错误用法以下是一个使用非懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 正确用法以下是一个使用懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 错误用法以下是一个使用非懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 正确用法以下是一个使用懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录
|
||
logger.info(f"Configured region_name: {config.region_name}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use lazy % formatting in logging functions (logging-fstring-interpolation) Detailslint 解释
错误用法以下是一个使用非懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 正确用法以下是一个使用懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 错误用法以下是一个使用非懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 正确用法以下是一个使用懒惰字符串格式化的示例: import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
username = "john_doe"
logger.debug("User %s logged in with ID %d" % (username, user_id)) 在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,9 +95,9 @@ def get_object_url( | |
return object_urls | ||
|
||
async def list_buckets(self, prefix: Optional[str] = None) -> List[dict]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing function or method docstring (missing-function-docstring) Detailslint 解释这个lint结果表明在代码中缺少函数或方法的文档字符串(docstring)。文档字符串是用于描述函数、类或模块用途和行为的字符串,通常放在定义之前。它有助于其他开发者理解代码的功能。 错误用法def calculate_sum(a, b):
return a + b 在这个例子中, 正确用法def calculate_sum(a, b):
"""
计算两个数的和
参数:
a (int): 第一个加数
b (int): 第二个加数
返回:
int: 两个数的和
"""
return a + b 在这个例子中,
|
||
""" | ||
List S3 buckets using async client with pagination | ||
""" | ||
if not self.config.buckets or len(self.config.buckets) == 0: | ||
return [] | ||
|
||
max_buckets = 50 | ||
|
||
async with self.s3_session.client( | ||
|
@@ -107,32 +107,22 @@ async def list_buckets(self, prefix: Optional[str] = None) -> List[dict]: | |
endpoint_url=self.config.endpoint_url, | ||
region_name=self.config.region_name, | ||
) as s3: | ||
if self.config.buckets: | ||
# If buckets are configured, only return those | ||
response = await s3.list_buckets() | ||
all_buckets = response.get("Buckets", []) | ||
# If buckets are configured, only return those | ||
response = await s3.list_buckets() | ||
all_buckets = response.get("Buckets", []) | ||
|
||
configured_bucket_list = [ | ||
bucket | ||
for bucket in all_buckets | ||
if bucket["Name"] in self.config.buckets | ||
] | ||
|
||
if prefix: | ||
configured_bucket_list = [ | ||
bucket | ||
for bucket in all_buckets | ||
if bucket["Name"] in self.config.buckets | ||
b for b in configured_bucket_list if b["Name"] > prefix | ||
] | ||
|
||
if prefix: | ||
configured_bucket_list = [ | ||
b for b in configured_bucket_list if b["Name"] > prefix | ||
] | ||
|
||
return configured_bucket_list[:max_buckets] | ||
else: | ||
# Default behavior if no buckets configured | ||
response = await s3.list_buckets() | ||
buckets = response.get("Buckets", []) | ||
|
||
if prefix: | ||
buckets = [b for b in buckets if b["Name"] > prefix] | ||
|
||
return buckets[:max_buckets] | ||
return configured_bucket_list[:max_buckets] | ||
|
||
async def list_objects( | ||
self, bucket: str, prefix: str = "", max_keys: int = 20, start_after: str = "" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing module docstring (missing-module-docstring) Detailslint 解释
错误用法以下是一个缺少模块文档字符串的示例: # version.py
def get_version():
return "1.0.0" 在这个例子中, 正确用法以下是添加了模块文档字符串的正确示例: """
This module provides functions to manage and retrieve the version information of the application.
"""
def get_version():
return "1.0.0" 在这个例子中,
|
||
VERSION = '1.1.0' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Final newline missing (missing-final-newline) Detailslint 解释这个lint结果表明在文件的末尾缺少一个换行符(final newline missing)。根据代码风格指南,每个文件应该以一个换行符结束,这样可以确保文件内容不会被其他文本意外地连接在一起。 错误用法# 这是一个错误的示例,文件末尾没有换行符
def example_function():
print("Hello, World!") 正确用法# 这是一个正确的示例,文件末尾有一个换行符
def example_function():
print("Hello, World!")
# 注意:在最后一行后面有一个空的换行符
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
from typing import List, Dict, Callable, Optional, Union, Awaitable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. standard import "typing.List" should be placed before third party import "fastjsonschema" (wrong-import-order) Detailslint 解释这个lint结果表明在代码中,标准库的导入语句(如 错误用法import fastjsonschema
from typing import List 在这个示例中, 正确用法from typing import List
import fastjsonschema 在这个示例中,
|
||
from dataclasses import dataclass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. standard import "dataclasses.dataclass" should be placed before third party import "fastjsonschema" (wrong-import-order) Detailslint 解释这个lint结果表明在代码文件中,标准库的导入语句应该放在第三方库的导入语句之前。具体来说, 错误用法import fastjsonschema
from dataclasses import dataclass 在这个示例中, 正确用法from dataclasses import dataclass
import fastjsonschema 在这个示例中,
|
||
from mcp import types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to import 'mcp' (import-error) Detailslint 解释这个lint结果表明在代码中尝试导入一个名为 错误用法# 错误的导入方式
import mcp 正确用法
通过以上步骤,你应该能够解决
|
||
from mcp_server import consts | ||
|
||
from .. import consts | ||
|
||
logger = logging.getLogger(consts.LOGGER_NAME) | ||
|
||
|
@@ -36,8 +37,8 @@ def all_tools() -> List[types.Tool]: | |
|
||
|
||
def register_tool( | ||
meta: types.Tool, | ||
func: Union[ToolFunc, AsyncToolFunc], | ||
meta: types.Tool, | ||
func: Union[ToolFunc, AsyncToolFunc], | ||
) -> None: | ||
"""注册工具,禁止重复名称""" | ||
name = meta.name | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lazy % formatting in logging functions (logging-fstring-interpolation)
Details
lint 解释
logging-fstring-interpolation
是一个lint规则,用于检查在日志记录函数中使用懒惰的%
格式化。这个规则建议使用更现代和易读的格式化方法,如 f-string 或str.format()
。错误用法
以下是一个使用
%
格式化的错误示例:在这个例子中,日志消息使用了
%
格式化方法。正确用法
以下是一个使用 f-string 的正确示例:
在这个例子中,日志消息使用了 f-string 格式化方法,这是一种更现代和易读的格式化方式。