Skip to content

Keep from python_utils.types import * working on Python 3.15 - #70

Merged
wolph merged 1 commit into
wolph:developfrom
maoxor:fix/python-3.15-star-import
Nov 1, 2026
Merged

wolph merged 1 commit into
wolph:developfrom
maoxor:fix/python-3.15-star-import

Conversation

@maoxor

@maoxor maoxor commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

On Python 3.15.0, from python_utils.types import * fails:

AttributeError: module 'python_utils.types' has no attribute 'ByteString'

3.15 removed typing.ByteString and typing.no_type_check_decorator, so from typing import * no longer brings them in, but both are still listed in __all__. import python_utils.types and attribute access keep working, and the whole suite passes on 3.15, which is why nothing caught it.

This lists those two names in __all__ only on Python < 3.15 (the same cut typing_extensions uses for no_type_check_decorator). On 3.10 to 3.14 the exported names don't change. I also added 3.15 to the CI matrix, the tox envs and the classifiers, so the new tests actually run there.

Two small choices you may want to know about:

  • # pragma: no cover rather than no branch, because tox -e coverage runs on a single interpreter, where a version-gated line is always missed on one side. It's the same pragma as the star imports just above.
  • __all__.extend(...) rather than +=: with +=, basedpyright reported __all__ as unknown in test_types.py.

Tests

Two regressions in test_types.py: every name in __all__ resolves, and the star import exports all of them. On 3.15 both fail without the change and pass with it; on 3.14 they pass either way.

What I ran (macOS arm64, CPython from uv)

  • tox -e py310,py311,py312,py313,py314,py315,lint,mypy,pyright,pyrefly,codespell,docs: all OK, 435 tests on each interpreter.
  • tox -e coverage on 3.10, 3.13 and 3.15: 100%. I also combined py310 + py314 + py315 data the way the CI coverage job does: 100%.
  • Built the wheel, installed it in a fresh 3.15 venv: python -W error -c "from python_utils.types import *" works.
  • Not run locally: PyPy.

Side note, unrelated to this change: running tox -p locally sometimes ends with an INTERNALERROR from coverage (FileNotFoundError while renaming a .coverage.* file), because the parallel envs share data files in the repo root. I hit it on develop too (1 run out of 5). Happy to send a separate PR if that's useful.

Python 3.15 removed `typing.ByteString` and
`typing.no_type_check_decorator`, so `from typing import *` no longer
provides them, but both were still listed in `__all__` and the star
import raised `AttributeError`. List them only on Python < 3.15.

Add regression tests that every `__all__` entry resolves and that the
star import exports all of them, and run the test suite on 3.15 in CI
and tox.
@maoxor
maoxor force-pushed the fix/python-3.15-star-import branch from 9b7b877 to c260f27 Compare October 29, 2026 16:00
@wolph
wolph merged commit 74e7333 into wolph:develop Nov 1, 2026
18 checks passed
wolph added a commit that referenced this pull request Nov 1, 2026
#70 appended ByteString and no_type_check_decorator to the end of
__all__ on Python 3.10 to 3.14. They stay at their 4.1.4 positions and
are removed only on 3.15, where typing no longer defines them. A test
pins the positions.
wolph added a commit that referenced this pull request Nov 1, 2026
@wolph

wolph commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thank you for the fix! I've moved the two names back to their old positions in __all__ for Python 3.10 to 3.14 (cf258d2) and added a changelog entry, but everything is merged beyond that :)

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