Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 17, 2025

Adding Ruff Linter Support to Stubs Quality Checks ✅

Issue: Check stubs with additional linters - specifically ruff
Status: COMPLETE

Implementation Summary

Successfully integrated Ruff as a third linter for MicroPython stubs quality checking, alongside Pyright and MyPy.

Completed Tasks

  • Explore repository structure and understand existing linting setup
  • Add ruff as a test dependency (pyproject.toml, requirements-test.txt)
  • Create typecheck_ruff.py module following the pattern of typecheck_mypy.py
  • Integrate ruff into typecheck.py infrastructure
  • Update test_snippets.py to include ruff in linter parametrization
  • Create test_ruff.py for dedicated ruff testing
  • Create feat_ruff test directory with sample files
  • Configure ruff to ignore common test snippet patterns (E402, etc.)
  • Update _configs/pyproject.toml with ruff configuration
  • Enable flake8-pyi (PYI) rules for stub-specific linting
  • Configure appropriate ignores for MicroPython stub characteristics
  • Verify ruff works on actual stub files (micropython-preview-docstubs passes)
  • Create comprehensive documentation (docs/29_ruff.md)
  • Add ruff badge to README
  • Update documentation index
  • Create integration summary (RUFF_INTEGRATION.md)
  • Fix CI error by adding requests to requirements-test.txt

Key Features

Fast linting: 10-100x faster than traditional linters
Stub-aware: Built-in flake8-pyi rules for .pyi files
Configured: Proper ignores for MicroPython stub characteristics
Integrated: Works seamlessly with existing pyright/mypy infrastructure
Documented: Complete usage guide and configuration examples

Files Changed

  • pyproject.toml (dependencies + configuration)
  • requirements-test.txt (dependencies + requests fix)
  • tests/quality_tests/typecheck_ruff.py (NEW)
  • tests/quality_tests/typecheck.py (ruff support)
  • tests/quality_tests/test_ruff.py (NEW)
  • tests/quality_tests/test_snippets.py (ruff in parametrization)
  • tests/quality_tests/_configs/pyproject.toml (ruff config)
  • tests/quality_tests/feat_ruff/ (NEW test directory)
  • docs/29_ruff.md (NEW documentation)
  • docs/index.md (updated TOC)
  • README.md (ruff badge)
  • RUFF_INTEGRATION.md (NEW summary)

Testing Results

✅ Ruff module imports successfully
✅ Runs on test directories without errors
✅ Validates stub files correctly (micropython-preview-docstubs passes)
✅ Configuration properly ignores MicroPython-specific patterns
✅ CI error fixed - requests module now in requirements-test.txt

Original prompt

This section details on the original issue you should resolve

<issue_title>Check stubs with additional linters </issue_title>
<issue_description>- [ ] flake8-py

  • pylint
  • ruff ?

</issue_description>

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

@Josverl Lets start adding ruff as that is frequently used.

Fixes #746


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Josverl Josverl added Quality QA of published stubs ruff ruff linter ( not yet tested in QA) labels Oct 17, 2025
Copilot AI changed the title [WIP] Add ruff linter for checking stubs Add Ruff linter support for stub quality checking with flake8-pyi rules Oct 17, 2025
Copilot AI requested a review from Josverl October 17, 2025 00:28
Copilot finished work on behalf of Josverl October 17, 2025 00:28
@Josverl
Copy link
Owner

Josverl commented Oct 17, 2025

@copilot
I see that one of the actions that runs the rest and the comparison has an error.

ModuleNotFoundError: No module named 'requests'

https://github.com/Josverl/micropython-stubs/actions/runs/18578590215/job/52969579062

Can you also fix that

Copy link
Contributor Author

Copilot AI commented Oct 17, 2025

@copilot
I see that one of the actions that runs the rest and the comparison has an error.
...

Fixed in commit d52ac09 - added requests to requirements-test.txt. The module was already in pyproject.toml but was missing from the requirements file used by the CI workflow.

Copilot finished work on behalf of Josverl October 17, 2025 07:45
@Josverl Josverl marked this pull request as ready for review October 17, 2025 09:26
@Josverl
Copy link
Owner

Josverl commented Oct 17, 2025

@copilot

@Josverl Josverl merged commit 78bf542 into main Oct 17, 2025
1 of 2 checks passed
@Josverl Josverl deleted the copilot/check-stubs-with-linters branch October 17, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Quality QA of published stubs ruff ruff linter ( not yet tested in QA)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check stubs with additional linters

2 participants