Repository navigation
chore: Python 3.15 idioms, and the 3.15 features evaluated - #23
Merged
Merged
Conversation
AsyncGenerator comes from collections.abc with the single type parameter 3.13+ allows; typing's alias is the deprecated spelling. scripts/release.py drops `from __future__ import annotations`, redundant since 3.14's deferred annotations, and uses re.prefixmatch, the explicit name 3.15 adds for match, which it soft-deprecates. No behaviour change. AGENTS.md records the rules. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Python 3.15's frozendict builtin for the four module-level mappings that are only read: _SECRET_MINIMUM_BYTES (config), _TAKEN_MESSAGES (services.users), _DESCRIPTIONS (schemas.errors) and SECTIONS (scripts/release.py). They are Mappings, so .get, .values() and subscripting are unchanged; a stray assignment is now a TypeError instead of a silent edit. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
scripts/release.py and its test decoded git and poetry output and read or wrote pyproject.toml and CHANGELOG.md with the default encoding. Python 3.15 makes UTF-8 that default (PEP 686) and advises naming it; every read_text, write_text and subprocess.run(text=True) now passes encoding="utf-8", and `python -X warn_default_encoding -W error::EncodingWarning` is clean for the app import and the pure test set. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
profiling.sampling (Tachyon) in dump, attach and run form with --async-aware, and the one fact that decides whether it works: reading another process's memory needs ptrace permission on Linux (scope 0, root or CAP_SYS_PTRACE), which `run` avoids by starting the server as its child. Tried on this machine: run works unprivileged, dump on a sibling is refused with ptrace_scope=1, as the text says. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…23) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
The move to 3.15 (#19 to #22) changed no source line. This PR makes the code read like a 3.15 project and records, as #14 did for 3.14, which 3.15 features were considered and why each was adopted or left aside. One commit per topic.
Adopted
frozendict(PEP 814) for the four module-level mappings that are only read:_SECRET_MINIMUM_BYTES,_TAKEN_MESSAGES,_DESCRIPTIONSand the release script'sSECTIONS. They areMappings, so.get,.values()and subscripting are unchanged; a stray assignment is now aTypeError. mypy 2.4, flake8 and black all know the builtin.collections.abcaliases:AsyncGenerator[AsyncSession]with the single parameter 3.13+ allows, indatabase.pyandtests/conftest.py, instead oftyping's deprecated spelling.re.prefixmatch: 3.15's explicit name formatch, which it soft-deprecates, in the threescripts/release.pycall sites. Same behaviour.read_text,write_textandsubprocess.run(text=True)inscripts/release.pyand its test passesencoding="utf-8".python -X warn_default_encoding -W error::EncodingWarningis clean for the app import and the pure test set, and this is what found the call sites.from __future__ import annotationsremoved from the release script, redundant since 3.14's deferred annotations.profiling.sampling, Tachyon) next to the asyncio introspection commands, indump,attachandrunform with--async-aware, plus the fact that decides whether it works: reading another process's memory needs ptrace permission on Linux, whichrunavoids by starting the server as its child. Tried here:runworks unprivileged,dumpon a sibling is refused with the defaultptrace_scope=1.AGENTS.mdtyping rule updated; changelog entry under Changed.Evaluated and left unused (recorded in the changelog)
Lazy imports (PEP 810; the server imports everything at startup, the release script starts in milliseconds),
sentinel(no sentinel pattern), unpacking in comprehensions (nothing to flatten),TaskGroup.cancel(no task groups), TypedDictclosedandTypeForm(no TypedDicts), free-threading and the JIT (nothing CPU-bound). Also checked and needing nothing: the 3.15 removals (the suite already ran with-W error), andimportlib.metadata.MetadataNotFound, whichconfig._package_versiondoes not need to catch.Verification, local on Python 3.15.0 with PostgreSQL 17
black, flake8, mypy clean; encoding audit clean;
scripts/release.py versionandcheck-version v0.1.0work; full suite, 140 passed, with-W error.🤖 Generated with Claude Code