-
Notifications
You must be signed in to change notification settings - Fork 8
feat: config ak/sk... support empty str #16
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
Changes from 1 commit
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 |
---|---|---|
|
@@ -29,13 +29,22 @@ class Config: | |
|
||
def load_config() -> Config: | ||
config = Config( | ||
access_key=os.getenv(_CONFIG_ENV_KEY_ACCESS_KEY, "QINIU_ACCESS_KEY"), | ||
secret_key=os.getenv(_CONFIG_ENV_KEY_SECRET_KEY, "QINIU_SECRET_KEY"), | ||
endpoint_url=os.getenv(_CONFIG_ENV_KEY_ENDPOINT_URL, "QINIU_ENDPOINT_URL"), | ||
region_name=os.getenv(_CONFIG_ENV_KEY_REGION_NAME, "QINIU_REGION_NAME"), | ||
access_key=os.getenv(_CONFIG_ENV_KEY_ACCESS_KEY), | ||
secret_key=os.getenv(_CONFIG_ENV_KEY_SECRET_KEY), | ||
endpoint_url=os.getenv(_CONFIG_ENV_KEY_ENDPOINT_URL), | ||
region_name=os.getenv(_CONFIG_ENV_KEY_REGION_NAME), | ||
buckets=_get_configured_buckets_from_env(), | ||
) | ||
|
||
if not config.access_key or len(config.access_key) == 0: | ||
config.access_key = "YOUR_QINIU_ACCESS_KEY" | ||
if not config.secret_key or len(config.access_key) == 0: | ||
config.secret_key = "YOUR_QINIU_SECRET_KEY" | ||
if not config.endpoint_url or len(config.access_key) == 0: | ||
config.endpoint_url = "YOUR_QINIU_ENDPOINT_URL" | ||
if not config.region_name or len(config.access_key) == 0: | ||
config.region_name = "YOUR_QINIU_REGION_NAME" | ||
|
||
logger.info(f"Configured access_key: {config.access_key}") | ||
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
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 格式化方法,这是一种更现代和易读的格式化方式。
|
||
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
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 提供了一种更简洁和易读的方式来格式化字符串。
|
||
|
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 解释
missing-function-docstring
是一个常见的代码质量检查,用于确保函数或方法有文档字符串(docstring)。文档字符串是用于描述函数、类或模块用途的字符串,通常放在函数定义的第一行。它有助于其他开发者理解代码的功能和使用方式。错误用法
以下是一个缺少函数文档字符串的示例:
在这个例子中,
calculate_area
函数没有文档字符串,这可能会导致其他开发者难以理解该函数的作用。正确用法
以下是添加了文档字符串的正确示例:
在这个例子中,
calculate_area
函数添加了一个文档字符串,详细描述了函数的功能、参数和返回值。这有助于提高代码的可读性和可维护性。