Skip to content

tooling: Replace wildcard imports with explicit imports (F403/F405).#298

Merged
nedseb merged 2 commits into
mainfrom
tooling/explicit-imports
Mar 28, 2026
Merged

tooling: Replace wildcard imports with explicit imports (F403/F405).#298
nedseb merged 2 commits into
mainfrom
tooling/explicit-imports

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 28, 2026

Summary

Replace all from module.const import * with explicit import lists across the entire codebase. Re-enable F401, F403, and F405 rules in ruff.

Changes

  • 28 files converted from wildcard to explicit imports
  • F401 (unused imports), F403 (wildcard imports), F405 (undefined from wildcard) re-enabled
  • Removed unused wildcard import from vl53l1x/const.py
  • Removed unused wildcard imports from 2 lis2mdl examples
  • Removed empty bq27441/exceptions.py import
  • Fixed duplicate imports (exceptions imported from both const and exceptions)

Drivers migrated

Driver Files Imports
apds9960 1 99
bq27441 1 50
daplink_bridge 1 11
daplink_flash 1 10
hts221 1 24
ism330dl 1 35
lis2mdl 1 15
mcp23009e 12 6-20 each
ssd1327 2 2-21
wsen-hids 1 40
wsen-pads 1 40

Closes #293

Test plan

  • make ci passes (196 mock tests + 271 example validations)
  • ruff check passes with F401/F403/F405 re-enabled
  • No wildcard imports remain in the codebase

BREAKING CHANGE: Wildcard imports removed across all drivers and examples.
F401, F403, and F405 rules re-enabled in ruff configuration.
Copilot AI review requested due to automatic review settings March 28, 2026 20:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes wildcard (import *) imports across the driver codebase to eliminate F403/F405 issues and re-enables Ruff’s unused/undefined import checks for stronger static analysis.

Changes:

  • Re-enabled Ruff rules F401/F403/F405 by removing them from the global ignore list.
  • Replaced wildcard imports with explicit import lists across multiple drivers and examples.
  • Removed an unused micropython.const import by emptying vl53l1x/const.py and added daplink_bridge README documentation.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Re-enables Ruff F401/F403/F405 by removing them from ignore.
lib/wsen-pads/wsen_pads/device.py Replaces wildcard const/exception imports with explicit imports.
lib/wsen-hids/wsen_hids/device.py Replaces wildcard const import with an explicit import list.
lib/vl53l1x/vl53l1x/const.py Removes unused const import by making the module empty.
lib/ssd1327/ssd1327/device.py Replaces wildcard const import with explicit imports used by the driver.
lib/ssd1327/ssd1327/init.py Replaces wildcard const import with explicit re-exports.
lib/mcp23009e/mcp23009e/pin.py Replaces wildcard const import with explicit imports.
lib/mcp23009e/mcp23009e/device.py Replaces wildcard const import with explicit imports; trims unused I2C import.
lib/mcp23009e/examples/sleep_on_button.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/simon.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/reaction_timer.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/morse_code.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/menu_navigation.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/dpad_piano.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/dpad_counter.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/combination_lock.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/buttons.py Replaces wildcard const import with explicit imports used in the example.
lib/mcp23009e/examples/binary_counter.py Replaces wildcard const import with explicit imports used in the example.
lib/lis2mdl/lis2mdl/device.py Replaces wildcard const import with explicit imports.
lib/lis2mdl/examples/magnet_fieldForce.py Removes unused wildcard const import from the example.
lib/lis2mdl/examples/magnet_compass.py Removes unused wildcard const import from the example.
lib/ism330dl/ism330dl/device.py Replaces wildcard const/exception imports with explicit imports.
lib/hts221/hts221/device.py Replaces wildcard const import with explicit imports; trims unused I2C import.
lib/daplink_flash/daplink_flash/device.py Replaces wildcard const import with explicit imports.
lib/daplink_bridge/daplink_bridge/device.py Replaces wildcard const import with explicit imports.
lib/daplink_bridge/README.md Adds usage/API documentation for the DAPLink bridge driver.
lib/bq27441/bq27441/device.py Replaces wildcard const/exception imports with an explicit const import list.
lib/apds9960/apds9960/device.py Replaces wildcard const/exception imports with explicit imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 28, 2026

Deux remarques traitées dans e35921a :

  1. _writeto/_readfrom dans le README daplink_bridge — faux positif, les helpers existent bien dans device.py (lignes 46 et 50). Pas de modification.
  2. Wildcard imports dans le README mcp23009e — corrigé. Les 3 snippets utilisent maintenant des imports explicites.

Plus aucun import * dans la codebase ni dans la documentation.

@nedseb nedseb merged commit 2874448 into main Mar 28, 2026
9 checks passed
@nedseb nedseb deleted the tooling/explicit-imports branch March 28, 2026 20:29
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.2.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: Replace wildcard imports with explicit imports (F403/F405).

2 participants