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

Add function type information to functions in NVDAObjects/JAB/init.py #16953

Merged
merged 7 commits into from
Aug 7, 2024

Conversation

alexsimon7
Copy link
Contributor

@alexsimon7 alexsimon7 commented Aug 4, 2024

Link to issue number:

Progress towards #13835

Summary of the issue:

Functions in NVDAObjects/JAB/init.py lack type information.

Description of user facing changes

N/A

Description of development approach

Added type information to functions where type was apparent.

Testing strategy:

N/A

Known issues with pull request:

None known.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Enhanced code clarity and maintainability through the addition of type annotations in key classes.
  • Improvements

    • Improved type safety and readability of methods in the JABTextInfo and JAB classes, making it easier for developers to understand method parameters and return types.

@alexsimon7 alexsimon7 requested a review from a team as a code owner August 4, 2024 13:42
@alexsimon7 alexsimon7 requested a review from seanbudd August 4, 2024 13:42
Copy link
Contributor

coderabbitai bot commented Aug 4, 2024

Walkthrough

The changes focus on enhancing type safety and code readability within the JABTextInfo and JAB classes by introducing extensive type annotations. This update clarifies method parameters and return types, aiding developers in understanding expected inputs and outputs. The modifications promote better maintainability of the codebase while facilitating static type checking.

Changes

Files Change Summary
source/NVDAObjects/JAB/__init__.py Added type annotations to methods in JABTextInfo and JAB classes, specifying parameter and return types for improved clarity and safety. Methods like _getOffsetFromPoint, _getBoundingRectFromOffset, findOverlayClasses, and _get_keyboardShortcut were updated to reflect their expected types.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant JABTextInfo
    participant JAB

    Developer->>JABTextInfo: Call _getOffsetFromPoint(x: int, y: int)
    JABTextInfo-->>Developer: Returns int

    Developer->>JABTextInfo: Call _getBoundingRectFromOffset(offset: int)
    JABTextInfo-->>Developer: Returns RectLTWH

    Developer->>JAB: Call findOverlayClasses(clsList)
    JAB-->>Developer: Returns None
Loading

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration 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
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

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

Can you please do a double-check to confirm these suggestions are right?
Please also make sure to add full type information where possible

source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
@seanbudd seanbudd marked this pull request as draft August 5, 2024 00:40
@alexsimon7
Copy link
Contributor Author

Yes. I'll do a double check on the suggestions. Can you confirm what you mean by full type information? Do you mean something like "tuple[int, int]" which you suggested? Thanks for the code review!

@seanbudd
Copy link
Member

seanbudd commented Aug 5, 2024

yep exactly that, tuple[int, int]. as specific types as possible. Thanks

@AppVeyorBot
Copy link

  • PASS: Translation comments check.
  • PASS: License check.
  • FAIL: Unit tests. See test results for more information.
  • FAIL: Lint check. See test results and lint artifacts for more information.
  • FAIL: System tests (tags: installer NVDA). See test results for more information.
  • Build (for testing PR): https://ci.appveyor.com/api/buildjobs/kb316w9lv46cyvpx/artifacts/output/nvda_snapshot_pr16953-33261,2f3794eb.exe
  • CI timing (mins):
    INIT 0.0,
    INSTALL_START 1.4,
    INSTALL_END 1.0,
    BUILD_START 0.0,
    BUILD_END 13.1,
    TESTSETUP_START 0.0,
    TESTSETUP_END 0.2,
    TEST_START 0.0,
    TEST_END 0.7,
    FINISH_END 0.1

See test results for failed build of commit 2f3794eb57

@AppVeyorBot
Copy link

See test results for failed build of commit 3e0124c8fb

@AppVeyorBot
Copy link

See test results for failed build of commit 60289d706f

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Aug 6, 2024
@alexsimon7
Copy link
Contributor Author

I reverted the RectLTRB change and fixed JABHandler.JABContext using a forward reference. That fixed (locally) the failed unit tests I was experiencing before. Thanks for the help!

@seanbudd seanbudd marked this pull request as ready for review August 7, 2024 06:20
source/NVDAObjects/JAB/__init__.py Outdated Show resolved Hide resolved
@seanbudd seanbudd closed this Aug 7, 2024
@seanbudd seanbudd reopened this Aug 7, 2024
@seanbudd seanbudd merged commit a748f9c into nvaccess:master Aug 7, 2024
1 of 3 checks passed
@alexsimon7
Copy link
Contributor Author

@seanbudd Thanks for the help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants