Skip to content

Document additional static type checking without a typing module #766

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

Closed
Josverl opened this issue Nov 1, 2024 · 0 comments · Fixed by #805
Closed

Document additional static type checking without a typing module #766

Josverl opened this issue Nov 1, 2024 · 0 comments · Fixed by #805
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@Josverl
Copy link
Owner

Josverl commented Nov 1, 2024

Document additional manner of static type checking without a typing module.

from machine import I2C

TYPE_CHECKING = False
if TYPE_CHECKING:
    from enum import IntEnum
    from typing import Optional
else:
    IntEnum = object
    Optional = object

ref: https://github.com/eosti/micropython-aw210xx/blob/main/src/aw210xx.py

@Josverl Josverl added the documentation Improvements or additions to documentation label Nov 1, 2024
@Josverl Josverl self-assigned this Nov 1, 2024
Josverl added a commit that referenced this issue Mar 17, 2025
Fixes #766

Add documentation for static type checking without a typing module.

* **`docs/22_static_type_checking.md`**:
  - Add a new section explaining the alternative method using `TYPE_CHECKING` and conditional imports.
  - Include a code example demonstrating how to use `TYPE_CHECKING` and conditional imports to perform static type checking without a typing module.

* **`docs/index.md`**:
  - Update the table of contents to include a link to the new section in `docs/22_static_type_checking.md`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Josverl/micropython-stubs/issues/766?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant