Repository navigation
chore: fix pre-commit.ci on Python 3.14; pass ruff 0.17 and mypy 2.x - #153
Draft
bluetoothbot wants to merge 3 commits into
Draft
bluetoothbot wants to merge 3 commits into
bluetoothbot wants to merge 3 commits into
Conversation
pre-commit.ci's autoupdate (Bluetooth-Devices#131) bumps ruff to 0.17 and mypy to 2.4, which flag code that the pinned versions accept. Its autofix commit leaves three ruff errors (EXE001, RUF015, PYI018) plus two mypy unused-ignore errors, and it adds a runtime `from typing import Self` that raises ImportError on Python 3.9/3.10, which pyproject.toml still declares as supported. Fix the code so both the pinned and the updated hook versions pass: - setup.py: drop the shebang (file is not executable in git) - docs conf.py: List -> list - __init__.py: sort __all__ - data.py: next(iter(...)) for primary_device_id; int | float -> float - enum.py: Self instead of a custom TypeVar, imported only under TYPE_CHECKING so runtime stays 3.9-compatible - test_init.py: assert str() before == so mypy 1.x does not mark the line unreachable and mypy 2.x does not flag an unused ignore
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #153 +/- ##
==========================================
+ Coverage 94.37% 95.82% +1.44%
==========================================
Files 12 12
Lines 480 479 -1
Branches 5 5
==========================================
+ Hits 453 459 +6
+ Misses 26 18 -8
- Partials 1 2 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 25, 2026
Author
|
This PR clears the red On
I checked this branch against #131's Merging this first should turn #131 green without any other changes. |
pyupgrade v3.21.0 calls tokenize.cookie_re.match() on str tokens. In Python 3.14 that pattern is bytes, so the hook raises TypeError on any file with a leading comment. pre-commit.ci now runs Python 3.14 by default, which is why it is red on every PR opened since early 2026 while the GitHub Actions lint job (3.11) stays green. Fixed upstream in 3.21.1; v3.22.0 matches the rev in the pending autoupdate (Bluetooth-Devices#131).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Make the code pass the hook versions in the pre-commit autoupdate PR #131 (ruff 0.17, mypy 2.4). The currently pinned versions still pass.
Why — pre-commit.ci is red on every open PR, and on main if it re-ran. pre-commit.ci now uses Python 3.14 by default. On 3.14, pyupgrade v3.21.0 raises
TypeError: cannot use a bytes pattern on a string-like objectbecausetokenize.cookie_rebecame a bytes pattern. The GitHub Actionslintjob runs on 3.11, so it stays green. That explains why every PR since early 2026 is red on pre-commit.ci only, while #132–#135 (Dec 2025/Jan 2026) were green. I reproduced it onmainwith Python 3.14.2 and 3.14.5. pyupgrade 3.21.2 and 3.22.0 fix it, so this PR bumps the rev to v3.22.0, the same line as #131.Also: #131 fails
pre-commit.ci. Newer ruff enables more rules by default, and the repo has no ruff config. pre-commit.ci's autofix commit fixes some of them but leaves:EXE001onsetup.py,RUF015ondata.py:99, andPYI018(the TypeVar left unused by its own fix)unused-ignoreerrors intests/test_init.pyThat autofix also adds a runtime
from typing import Selftoenum.py. That import raisesImportErroron Python 3.9 and 3.10, whichpyproject.tomlstill declares as supported (^3.9). CI only tests 3.11+, so CI wouldn't catch it.How:
.pre-commit-config.yaml: pyupgradev3.21.0→v3.22.0. chore(pre-commit.ci): pre-commit autoupdate #131 makes the same change, so the two don't conflict.enum.py: useSelfinstead of the custom TypeVar, imported only underTYPE_CHECKING. The module already hasfrom __future__ import annotations, soSelfis never evaluated at runtime. This works with or without feat: require Python 3.11 or later #152.setup.py: removed the shebang. The file isn't executable in git, andpython setup.pystill works.data.py:next(iter(...))inprimary_device_id.int | floatbecomesfloatin the twonative_valueannotations. The type is unchanged, because type checkers already acceptintwherefloatis expected.__init__.py: sorted__all__.docs/source/conf.py:Listbecomeslist. This is the same change feat: require Python 3.11 or later #152 makes, so the two merge without conflict.tests/test_init.py: assertstr(x)beforex == "...". mypy 1.x no longer reports the line as unreachable, so thetype: ignorecomments aren't needed, and mypy 2.x has nothing to report as unused.Testing: I ran
pre-commit run --all-fileson this branch withdefault_language_versionset to python3.11 and then to python3.14. All 20 hooks pass in both, including prettier with system Node 24.Earlier testing: I ran the cached hook binaries with
--isolated, so no parent ruff config was picked up:checkandformat: cleantest_primary_device_id. Line 99 changed here and had no test on main, which madecodecov/patchfail on the first push.I also merged this branch onto main together with all 13 open koan PRs. There were no conflicts and 84 tests pass. The only new-ruff finding in the combined tree was a
B017in #142's test, which I fixed on that branch. The exact versions in #131 (ruff 0.17.1, mypy 2.4.0) aren't available offline here, so check #131's run after this merges.🤖 Generated with Claude Code