Skip to content

Conversation

@pantheraleo-7
Copy link
Contributor

merge after #101 is merged.

based on #101(comment)

@pantheraleo-7
Copy link
Contributor Author

Just realised, this is present in many libraries. An automated patch might be a better approach than manual PRs.

Automating quoting the symbols might be error prone, so adding this import should do the [same] job:
from __future__ import annotations

This enables lazy evaluation of type annotations in Python 3.7+

@pantheraleo-7 pantheraleo-7 force-pushed the type-hint-forward-reference branch from 3f215d5 to 147ca85 Compare October 7, 2025 17:39
@pantheraleo-7 pantheraleo-7 changed the title change to forward reference for possibly unbound objects in type hint(s) change to forward reference for possibly unbound symbols in type hint(s) Oct 7, 2025
@FoamyGuy
Copy link
Contributor

FoamyGuy commented Oct 8, 2025

using from __future__ import annotations might be easier than trying to update things to use quoted references. I think we added that as an import in the core that exists to make it compatible with that behavior.

We can try searching in the bundle to find ones that have this stuff in the except block of their guarded typing import.

@pantheraleo-7
Copy link
Contributor Author

The PR on INA219 is required because it removes the I2C = None thing. But this PR becomes optional, as I2C = None already got removed by #101, if you intend to include the from __future__ import annotations import via an automated script/method.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

We can merge this now, and still consider a more broad solution down the line.

Thanks for contributing!

@FoamyGuy FoamyGuy merged commit d56c704 into adafruit:main Nov 4, 2025
1 check passed
adafruit-adabot pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 5, 2025
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 3.0.2 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#107 from pantheraleo-7/type-hint-forward-reference

Updating https://github.com/adafruit/Adafruit_CircuitPython_ATECC to 1.3.0 from 1.2.25:
  > Merge pull request adafruit/Adafruit_CircuitPython_ATECC#38 from CaptainHaddock2016/patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_ATECC#40 from akgamerz790/fix-issuer-subject-length-bug
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