Skip to content

Add back SCM - #12

Merged
hbmartin merged 2 commits into
masterfrom
hm/readd-scm
Aug 13, 2025
Merged

Add back SCM#12
hbmartin merged 2 commits into
masterfrom
hm/readd-scm

Conversation

@hbmartin

@hbmartin hbmartin commented Aug 12, 2025

Copy link
Copy Markdown
Owner

PR Type

Enhancement


Description

  • Version bump from 3.4.0 to 3.4.1

  • Add SharedCentralManager class to Bluetooth stubs

  • Remove type ignore comment for _cb import

  • Add shared_manager global variable


Diagram Walkthrough

flowchart LR
  A["VERSION file"] -- "bump" --> B["3.4.1"]
  C["cb.pyi stubs"] -- "add" --> D["SharedCentralManager class"]
  C -- "add" --> E["shared_manager variable"]
  C -- "clean" --> F["import statement"]
Loading

File Walkthrough

Relevant files
Configuration changes
VERSION
Version bump to 3.4.1                                                                       

VERSION

  • Bump version from 3.4.0 to 3.4.1
+1/-1     
Enhancement
cb.pyi
Add SharedCentralManager class and clean imports                 

stubs/pythonista_stubs/cb.pyi

  • Add SharedCentralManager class extending CentralManager
  • Add shared_manager global variable declaration
  • Remove type ignore comment from _cb import
  • Include reference to GitHub PR documentation
+9/-1     

Summary by Sourcery

Add SharedCentralManager stub and shared_manager global to bluetooth stubs, clean up import, and bump package version

New Features:

  • Introduce SharedCentralManager class in the Bluetooth stubs
  • Expose shared_manager global variable of type SharedCentralManager

Enhancements:

  • Remove redundant type ignore comment on _cb import
  • Bump version from 3.4.0 to 3.4.1

Summary by CodeRabbit

  • New Features
    • Improved Bluetooth management typings: adds a shared central manager with delegate support, verbosity controls, and scanning helpers to improve editor autocomplete and developer ergonomics.
  • Chores
    • Bumped package version to 3.4.1; no functional or behavioral changes.

Important

Add SharedCentralManager class and shared_manager variable to cb.pyi, remove type ignore comment, and bump version to 3.4.1.

  • Enhancements:
    • Add SharedCentralManager class in cb.pyi, extending CentralManager with delegate and verbose attributes.
    • Introduce shared_manager global variable of type SharedCentralManager in cb.pyi.
    • Remove type ignore comment from _cb import in cb.pyi.
    • Bump version from 3.4.0 to 3.4.1 in VERSION.

This description was created by Ellipsis for d64a8c6. You can customize this summary. It will automatically update as commits are pushed.

@hbmartin
hbmartin requested a review from o-murphy August 12, 2025 21:42
@coderabbitai

coderabbitai Bot commented Aug 12, 2025

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Bumps VERSION 3.4.0 → 3.4.1 and updates Pythonista Bluetooth stubs: removes a type-ignore on an internal import, adds a SharedCentralManager subclass, a shared_manager symbol, and new functions set_central_delegate, set_verbose, and scan_for_peripherals.

Changes

Cohort / File(s) Summary
Version bump
VERSION
Updated version string from 3.4.0 to 3.4.1.
Pythonista Bluetooth stubs
stubs/pythonista_stubs/cb.pyi
Removed # type: ignore[import-not-found] on _cb import; added SharedCentralManager(CentralManager) with `delegate: _CentralManagerDelegate

Sequence Diagram(s)

sequenceDiagram
  actor App
  participant cb as cb module
  participant SCM as SharedCentralManager
  participant Del as _CentralManagerDelegate

  App->>cb: set_central_delegate(delegate)
  cb->>SCM: shared_manager.delegate = delegate
  App->>cb: set_verbose(true)
  cb->>SCM: shared_manager.verbose = true
  App->>cb: scan_for_peripherals()
  cb->>SCM: shared_manager.start_scan()
  SCM-->>Del: delegate callbacks
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I nibble bytes beneath the moon,
version hopped — a tiny tune.
A shared manager wakes to scan,
verbose whispers through the bran.
Rabbit logs the Bluetooth bloom. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffa9397 and d64a8c6.

📒 Files selected for processing (1)
  • stubs/pythonista_stubs/cb.pyi (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • stubs/pythonista_stubs/cb.pyi
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hm/readd-scm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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.
  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary of Changes

Hello @hbmartin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on updating the project's version and refining the type stubs for Pythonista's Core Bluetooth (cb) module. It increments the version number and reintroduces or clarifies the SharedCentralManager class and its associated global instance within the cb.pyi stub file. This change likely aims to improve type checking and provide more accurate autocompletion for users interacting with the Core Bluetooth functionalities in Pythonista, specifically regarding the shared central manager.

Highlights

  • Version Update: The project version has been incremented from 3.4.0 to 3.4.1.
  • Type Hint Refinement: The type: ignore[import-not-found] comment has been removed from the _cb import in cb.pyi, suggesting improved module discoverability or type checking accuracy.
  • Shared Central Manager Reintroduction: The SharedCentralManager class, along with its delegate, verbose properties, and verbose_log method, has been added to the cb.pyi stub file. A global shared_manager instance has also been introduced.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Bump version to 3.4.1 and update Bluetooth stubs by cleaning import directives, adding a SharedCentralManager subclass, and declaring a shared_manager global variable.

Class diagram for SharedCentralManager and shared_manager additions

classDiagram
    class CentralManager
    class _CentralManagerDelegate
    class SharedCentralManager {
        delegate: _CentralManagerDelegate | None
        verbose: bool
        verbose_log(): None
    }
    SharedCentralManager --|> CentralManager
    shared_manager: SharedCentralManager | None
Loading

Flow diagram for PR changes overview

flowchart LR
  A[VERSION file] -- "bump" --> B[3.4.1]
  C[cb.pyi stubs] -- "add" --> D[SharedCentralManager class]
  C -- "add" --> E[shared_manager variable]
  C -- "clean" --> F[import statement]
Loading

File-Level Changes

Change Details Files
Bump project version
  • Increment version from 3.4.0 to 3.4.1
VERSION
Enhance Bluetooth stub definitions
  • Remove type ignore comment on _cb import
  • Add SharedCentralManager class with delegate and verbose support
  • Declare shared_manager global variable
stubs/pythonista_stubs/cb.pyi

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Type Consistency

Confirm that the newly introduced SharedCentralManager attributes (delegate, verbose) and method (verbose_log) accurately reflect the runtime API and CentralManager base class behavior to avoid mismatch between stubs and implementation.

class SharedCentralManager(CentralManager):
    delegate: _CentralManagerDelegate | None = None
    verbose: bool = False
    def verbose_log(self) -> None: ...

shared_manager: SharedCentralManager | None
Global Variable Semantics

Validate that the type of shared_manager as Optional[SharedCentralManager] matches how it is actually exposed at runtime (module-level singleton vs. factory) and that forward references and import order won’t cause typing issues.

shared_manager: SharedCentralManager | None
Import Robustness

Removing the type ignore on _cb import may reintroduce typing/import errors in environments lacking the compiled module; ensure stub packages or typing-only guards are in place.

from _cb import (
    CH_PROP_AUTHENTICATED_SIGNED_WRITES,
    CH_PROP_BROADCAST,
    CH_PROP_EXTENDED_PROPERTIES,
    CH_PROP_INDICATE,

@qodo-code-review

qodo-code-review Bot commented Aug 12, 2025

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Correct stub attribute declarations
Suggestion Impact:The commit removed the default value from delegate, kept verbose with a default (partially matching), and added a default None to shared_manager. It also exported SharedCentralManager and shared_manager.

code diff:

@@ -83,11 +85,11 @@
 
 # Documented at https://github.com/hbmartin/pythonista-stubs/pull/11#issuecomment-3180673698
 class SharedCentralManager(CentralManager):
-    delegate: _CentralManagerDelegate | None = None
+    delegate: _CentralManagerDelegate | None
     verbose: bool = False
     def verbose_log(self) -> None: ...
 
-shared_manager: SharedCentralManager | None
+shared_manager: SharedCentralManager | None = None
 
 def set_central_delegate(delegate: _CentralManagerDelegate) -> None: ...
 def set_verbose(flag: bool) -> None: ...

Avoid assigning default values to class attributes in a .pyi stub unless they
are true constants; it can imply different runtime behavior and shadow instance
attributes. Remove the initializers to reflect types only, and provide a default
value for the global to match typical module semantics.

stubs/pythonista_stubs/cb.pyi [85-90]

 class SharedCentralManager(CentralManager):
-    delegate: _CentralManagerDelegate | None = None
-    verbose: bool = False
+    delegate: _CentralManagerDelegate | None
+    verbose: bool
     def verbose_log(self) -> None: ...
 
-shared_manager: SharedCentralManager | None
+shared_manager: SharedCentralManager | None = None

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly improves the stub file by removing default values from class attributes and adding one to a global variable, which aligns with best practices for .pyi files and improves type hint accuracy.

Low
  • Update

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @hbmartin - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request correctly re-introduces SharedCentralManager and the shared_manager global to the cb.pyi stubs, enhancing type support for the library. The version bump and import cleanup are also appropriate. My review includes one suggestion to update the module's __all__ declaration to include the new symbols, which is important for maintaining a clear public API.

Comment thread stubs/pythonista_stubs/cb.pyi Outdated

@ellipsis-dev ellipsis-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to ffa9397 in 1 minute and 46 seconds. Click for details.
  • Reviewed 37 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. VERSION:1
  • Draft comment:
    Version bump to 3.4.1 looks correct; consider adding a trailing newline for style consistency.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_Y8CQaZ0PXpJTjRLj

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Comment thread stubs/pythonista_stubs/cb.pyi
Comment thread stubs/pythonista_stubs/cb.pyi

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
stubs/pythonista_stubs/cb.pyi (2)

30-60: Export new public symbols via all.

You introduced SharedCentralManager and shared_manager as public, but they are not in __all__. In stubs, __all__ constrains star-imported names; omitting these can hide them from from cb import * and tooling that reads __all__.

Apply this diff to add the new symbols to __all__:

 __all__ = (
@@
     "reset",
     "scan_for_peripherals",
     "set_central_delegate",
     "set_verbose",
     "stop_scan",
+    "SharedCentralManager",
+    "shared_manager",
 )

84-90: Initialize shared_manager to None for clarity and consistency.

Declaring a default signals intended runtime value and aligns with how you annotated delegate and verbose.

Apply this diff:

-shared_manager: SharedCentralManager | None
+shared_manager: SharedCentralManager | None = None
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e50bf9a and ffa9397.

📒 Files selected for processing (2)
  • VERSION (1 hunks)
  • stubs/pythonista_stubs/cb.pyi (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
stubs/pythonista_stubs/cb.pyi (1)
stubs/_cb.pyi (1)
  • CentralManager (83-111)
🔇 Additional comments (2)
VERSION (1)

1-1: Patch version bump looks correct for stub additions.

3.4.1 is appropriate for adding non-breaking typings. No further action needed.

stubs/pythonista_stubs/cb.pyi (1)

7-28: _cb.pyi stub is included in the package

  • stubs/_cb.pyi is present in the repo.
  • pyproject.toml maps stubs/ to the pythonista_stubs package and tool.setuptools.package-data "*": ["**/*"] ensures every .pyi under stubs/ (including _cb.pyi) is bundled.
  • There are no manifest entries that would omit _cb.pyi from the sdist or wheel.

The # type: ignore[import-not-found] can safely be dropped—_cb.pyi will be discoverable by consumers’ type checkers.

@hbmartin

Copy link
Copy Markdown
Owner Author

@o-murphy how does this look? I defer to your expertise here so feel free to push other cb changes onto this branch

@ellipsis-dev ellipsis-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed d64a8c6 in 1 minute and 35 seconds. Click for details.
  • Reviewed 34 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. stubs/pythonista_stubs/cb.pyi:88
  • Draft comment:
    Consider initializing 'delegate' to None if that's the intended default. Explicit defaults in stubs can clarify runtime behavior.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This is a type stub file where the primary purpose is to define types. The current annotation already indicates delegate can be None through the Union type. Adding an explicit default doesn't provide additional type information. The verbose field has a default likely because it represents a meaningful default state, while delegate being None may just be an uninitialized state. The comment could be valid if there's runtime behavior where delegate always starts as None, and making that explicit in stubs helps developers. The original code may have had a reason for omitting the default. While explicit defaults can be helpful, in a stub file the Union type already fully captures the type information. The runtime behavior is sufficiently documented by the type annotation alone. The comment should be deleted as it suggests a style preference that doesn't add meaningful type information in this context.
2. stubs/pythonista_stubs/cb.pyi:92
  • Draft comment:
    The global 'shared_manager' now explicitly defaults to None. Verify that this matches the intended initialization behavior at runtime.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to verify the intended behavior, which is against the rules. It does not provide a specific suggestion or point out a clear issue with the code.
3. stubs/pythonista_stubs/cb.pyi:51
  • Draft comment:
    New symbols ('SharedCentralManager' and 'shared_manager') are added to all. Consider grouping related symbols together for clarity and easier maintenance.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. stubs/pythonista_stubs/cb.pyi:7
  • Draft comment:
    Removal of the type ignore comment from the _cb import improves type safety. Confirm that _cb now provides the necessary type information.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_JTLfvbg963iGZKW7

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@o-murphy o-murphy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm ok with it

@hbmartin
hbmartin merged commit 81e3bc1 into master Aug 13, 2025
2 checks passed
@hbmartin
hbmartin deleted the hm/readd-scm branch August 13, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants