Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

MicroPython PR #18367 introduces a hard parameter to control Timer callback execution context (hard interrupt vs soft interrupt). The reference stubs need updating to reflect this API change.

Changes

  • reference/micropython/machine/Timer.pyi

    • Added hard: bool | None = None parameter to all __init__ and init overloads that accept initialization parameters
    • Added documentation for hard parameter behavior (hard/soft interrupt context tradeoffs)
  • tests/quality_tests/feat_machine/check_machine/check_Timer_hard.py

    • Test coverage for new parameter usage patterns

Example Usage

from machine import Timer

def callback(t):
    pass

# Hard interrupt - minimal latency, no heap allocation
tim = Timer(-1, mode=Timer.PERIODIC, freq=1000, callback=callback, hard=True)

# Soft interrupt - allows heap allocation, may have GC jitter
tim.init(period=100, callback=callback, hard=False)

The parameter is optional with port-specific defaults for backward compatibility.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/micropython/micropython/pulls/18367
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Adjust machine.Timer signature</issue_title>
<issue_description>micropython/micropython#18367

The reference stubs for machine.Timer will need an additional @overload for the constructie.

The docstring update should flow down from the docs automatically.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Copilot AI changed the title [WIP] Add overload for machine.Timer constructor Add hard parameter to machine.Timer signatures Nov 10, 2025
Copilot AI requested a review from Josverl November 10, 2025 20:54
Copilot finished work on behalf of Josverl November 10, 2025 20:54
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.

Adjust machine.Timer signature

2 participants