-
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
Conversation
@@ -7,7 +7,8 @@ | |||
from typing import List, Dict, Callable, Optional, Union, Awaitable | |||
from dataclasses import dataclass | |||
from mcp import types |
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.
Unable to import 'mcp' (import-error)
Details
lint 解释
这个lint结果表明在代码中尝试导入一个名为 mcp
的模块,但该模块无法被找到。这通常是因为模块路径配置不正确或者模块本身不存在。
错误用法
# 错误的导入方式
import mcp
正确用法
-
确保模块存在:
- 确认
mcp
模块是否存在于你的项目目录中,或者是否安装在你的Python环境中。
- 确认
-
检查模块路径:
- 如果
mcp
是一个自定义模块,确保它位于你的Python路径中。可以通过以下方式添加路径:import sys sys.path.append('/path/to/your/module') import mcp
- 如果
-
安装第三方模块:
- 如果
mcp
是一个第三方模块,确保你已经通过包管理工具(如pip
)正确安装了它:pip install mcp
- 如果
-
使用相对导入或绝对导入:
- 确保你在正确的文件中进行导入。例如,如果你在一个包的子目录中,应该使用相对导入:
from .. import mcp
- 或者使用绝对导入:
from your_package import mcp
- 确保你在正确的文件中进行导入。例如,如果你在一个包的子目录中,应该使用相对导入:
通过以上步骤,你应该能够解决 Unable to import 'mcp' (import-error)
的问题。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
@@ -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 comment
The 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)
Details
lint 解释
这个lint结果表明在代码中,标准库的导入语句(如 typing.List
)应该放在第三方库的导入语句之前。这样可以保持代码的可读性和一致性。
错误用法
import fastjsonschema
from typing import List
在这个示例中,fastjsonschema
是一个第三方库的导入语句,而 typing.List
是标准库的导入语句。正确的顺序应该是先导入标准库的模块,然后再导入第三方库的模块。
正确用法
from typing import List
import fastjsonschema
在这个示例中,typing.List
的导入语句放在了 fastjsonschema
之前,符合lint规则的要求。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
@@ -7,7 +7,8 @@ | |||
from typing import List, Dict, Callable, Optional, Union, Awaitable | |||
from dataclasses import dataclass |
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.
standard import "dataclasses.dataclass" should be placed before third party import "fastjsonschema" (wrong-import-order)
Details
lint 解释
这个lint结果表明在代码文件中,标准库的导入语句应该放在第三方库的导入语句之前。具体来说,dataclasses.dataclass
是Python标准库的一部分,而 fastjsonschema
是一个第三方库。
错误用法
import fastjsonschema
from dataclasses import dataclass
在这个示例中,fastjsonschema
的导入语句在 dataclasses
的导入语句之前,违反了lint规则。
正确用法
from dataclasses import dataclass
import fastjsonschema
在这个示例中,dataclasses
的导入语句放在了 fastjsonschema
的导入语句之前,符合lint规则。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Missing function or method docstring (missing-function-docstring)
Details
lint 解释
这个lint结果表明在代码中缺少函数或方法的文档字符串(docstring)。文档字符串是用于描述函数、类或模块用途和行为的字符串,通常放在定义之前。它有助于其他开发者理解代码的功能。
错误用法
def calculate_sum(a, b):
return a + b
在这个例子中,calculate_sum
函数缺少文档字符串。
正确用法
def calculate_sum(a, b):
"""
计算两个数的和
参数:
a (int): 第一个加数
b (int): 第二个加数
返回:
int: 两个数的和
"""
return a + b
在这个例子中,calculate_sum
函数添加了一个文档字符串,描述了函数的功能、参数和返回值。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
@@ -0,0 +1,2 @@ | |||
|
|||
VERSION = '1.1.0' |
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.
Final newline missing (missing-final-newline)
Details
lint 解释
这个lint结果表明在文件的末尾缺少一个换行符(final newline missing)。根据代码风格指南,每个文件应该以一个换行符结束,这样可以确保文件内容不会被其他文本意外地连接在一起。
错误用法
# 这是一个错误的示例,文件末尾没有换行符
def example_function():
print("Hello, World!")
正确用法
# 这是一个正确的示例,文件末尾有一个换行符
def example_function():
print("Hello, World!")
# 注意:在最后一行后面有一个空的换行符
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
@@ -0,0 +1,2 @@ | |||
|
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.
Missing module docstring (missing-module-docstring)
Details
lint 解释
missing-module-docstring
是一个常见的代码质量检查,用于确保每个模块(即 .py
文件)都有一个文档字符串。文档字符串是位于文件顶部的字符串,通常用三引号括起来,用于描述模块的功能和用途。
错误用法
以下是一个缺少模块文档字符串的示例:
# version.py
def get_version():
return "1.0.0"
在这个例子中,version.py
文件没有包含任何文档字符串。
正确用法
以下是添加了模块文档字符串的正确示例:
"""
This module provides functions to manage and retrieve the version information of the application.
"""
def get_version():
return "1.0.0"
在这个例子中,version.py
文件顶部包含了一个文档字符串,描述了该模块的功能。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
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}") |
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()
。
错误用法
以下是一个使用 %
格式化的错误示例:
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
logger.debug("User ID: %d" % user_id)
在这个例子中,日志消息使用了 %
格式化方法。
正确用法
以下是一个使用 f-string 的正确示例:
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
user_id = 123
logger.debug(f"User ID: {user_id}")
在这个例子中,日志消息使用了 f-string 格式化方法,这是一种更现代和易读的格式化方式。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
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 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规则,用于检查在日志记录函数中使用懒惰的字符串格式化(lazy string formatting)。懒惰的字符串格式化意味着只有在实际需要时才进行字符串格式化,而不是在记录日志时就立即进行。这可以提高性能,特别是在日志级别设置为不记录某些信息时。
错误用法
以下是一个使用非懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
正确用法
以下是一个使用懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
错误用法
以下是一个使用非懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
正确用法
以下是一个使用懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
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}") | ||
logger.info(f"Configured region_name: {config.region_name}") |
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规则,用于检查在日志记录函数中使用懒惰的字符串格式化(lazy string formatting)。懒惰的字符串格式化意味着只有在实际需要时才进行字符串格式化,而不是在记录日志时就立即进行。这可以提高性能,特别是在日志级别设置为不记录某些信息时。
错误用法
以下是一个使用非懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
正确用法
以下是一个使用懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
错误用法
以下是一个使用非懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
正确用法
以下是一个使用懒惰字符串格式化的示例:
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))
在这个例子中,字符串格式化在记录日志时立即进行,即使日志级别设置为不记录 DEBUG
级别的信息。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
支持不配置 Bucket