Skip to content
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

Update api.py #484

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update api.py #484

wants to merge 2 commits into from

Conversation

WangJieCIFCO
Copy link

@WangJieCIFCO WangJieCIFCO commented May 25, 2024

为TqApi类初始化方法添加一个deadline参数,默认设置为60秒。解决用户无法指定初始化接口的超时时间,以前默认超时为60秒,或许有些太长。

Summary by CodeRabbit

  • 新功能
    • TqApi 类的初始化方法新增了一个可选参数 deadline,用于设定等待更新的时间。

为API添加一个deadline参数,默认为60秒,
Copy link

coderabbitai bot commented May 25, 2024

Walkthrough

Walkthrough

本次更新对 TqApi 类的 __init__ 方法进行了修改,增加了一个可选的 deadline 参数,并在方法内部使用 _deadline 代替 deadline 来等待更新。这使得用户可以自定义等待时间,提升了灵活性。

Changes

文件路径 更改摘要
tqsdk/api.py - TqApi 类的 __init__ 方法新增可选参数 deadline
- 使用 _deadline 替代 deadline 进行等待更新

在代码的世界里,时间如流水,
新增的参数,灵活又自由。
兔子编程,效率如风,
等待不再漫长,更新更从容。

Tip

New Features and Improvements

Review Settings

Introduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments.

AST-based Instructions

CodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation.

Community-driven AST-based Rules

We are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information.

New Static Analysis Tools

We are continually expanding our support for static analysis tools. We have added support for biome, hadolint, and ast-grep. Update the settings in your .coderabbit.yaml file or head over to the settings page to enable or disable the tools you want to use.

Tone Settings

Users can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:

  • Mr. T: "You must talk like Mr. T in all your code reviews. I pity the fool who doesn't!"
  • Pirate: "Arr, matey! Ye must talk like a pirate in all yer code reviews. Yarrr!"
  • Snarky: "You must be snarky in all your code reviews. Snark, snark, snark!"

Revamped Settings Page

We have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to .coderabbit.yaml will be reflected in the settings page, and vice versa.

Miscellaneous

  • Turn off free summarization: You can switch off free summarization of PRs opened by users not on a paid plan using the enable_free_tier setting.
  • Knowledge-base scope: You can now set the scope of the knowledge base to either the repository (local) or the organization (global) level using the knowledge_base setting. In addition, you can specify Jira project keys and Linear team keys to limit the knowledge base scope for those integrations.
  • High-level summary placement: You can now customize the location of the high-level summary in the PR description using the high_level_summary_placeholder setting (default @coderabbitai summary).
  • Revamped request changes workflow: You can now configure CodeRabbit to auto-approve or request changes on PRs based on the review feedback using the request_changes_workflow setting.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1734bd5 and 362ef84.
Files selected for processing (1)
  • tqsdk/api.py (2 hunks)
Additional Context Used
Ruff (15)
tqsdk/api.py (15)

433-433: f-string without any placeholders


559-559: f-string without any placeholders


561-561: f-string without any placeholders


1253-1253: f-string without any placeholders


1264-1264: f-string without any placeholders


1468-1468: f-string without any placeholders


1529-1529: f-string without any placeholders


1591-1591: f-string without any placeholders


1816-1819: Do not assign a lambda expression, use a def


2243-2243: f-string without any placeholders


2339-2339: f-string without any placeholders


2341-2341: f-string without any placeholders


2716-2716: Do not compare types, use isinstance()


4026-4026: Do not assign a lambda expression, use a def


4031-4031: Do not use bare except

Additional comments not posted (1)
tqsdk/api.py (1)

94-94: 新增 deadline 参数以允许用户设置超时时间,这提高了灵活性和用户体验。

tqsdk/api.py Outdated
Comment on lines 293 to 298
_deadline = time.time() + deadline
try:
# 多账户时,所有账户需要初始化完成
trade_more_data = True
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=deadline): # 等待连接成功并收取截面数据
if not self.wait_update(_deadline=deadline): # 等待连接成功并收取截面数据
Copy link

@coderabbitai coderabbitai bot May 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait_update 方法调用中,应将参数名从 _deadline 改为 deadline,以保持一致性和清晰性。

- if not self.wait_update(_deadline=deadline):
+ if not self.wait_update(deadline=_deadline):

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
_deadline = time.time() + deadline
try:
# 多账户时,所有账户需要初始化完成
trade_more_data = True
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=deadline): # 等待连接成功并收取截面数据
if not self.wait_update(_deadline=deadline): # 等待连接成功并收取截面数据
_deadline = time.time() + deadline
try:
# 多账户时,所有账户需要初始化完成
trade_more_data = True
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=_deadline): # 等待连接成功并收取截面数据

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写错了。。。 SORRY

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WangJieCIFCO, no worries at all! If there's anything else you need help with or if you have further modifications, feel free to let me know. I'm here to help! 😊

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 362ef84 and f08496d.
Files selected for processing (1)
  • tqsdk/api.py (2 hunks)
Additional Context Used
Ruff (15)
tqsdk/api.py (15)

433-433: f-string without any placeholders


559-559: f-string without any placeholders


561-561: f-string without any placeholders


1253-1253: f-string without any placeholders


1264-1264: f-string without any placeholders


1468-1468: f-string without any placeholders


1529-1529: f-string without any placeholders


1591-1591: f-string without any placeholders


1816-1819: Do not assign a lambda expression, use a def


2243-2243: f-string without any placeholders


2339-2339: f-string without any placeholders


2341-2341: f-string without any placeholders


2716-2716: Do not compare types, use isinstance()


4026-4026: Do not assign a lambda expression, use a def


4031-4031: Do not use bare except

Additional comments not posted (1)
tqsdk/api.py (1)

94-94: 添加了新的可选参数 deadline,默认值为 60,这允许用户自定义初始化接口的超时时间。这是一个积极的改变,可以提高 API 的灵活性和用户体验。

tqsdk/api.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants