Commit Graph
4 Commits
Author SHA1 Message Date
montjeffrey 25c838253f test(clv2): keep the compatibility self-test passing on Python 3.8-3.11
Before 3.12 the parser rejects f"{d["k"]}" outright, so the shared sample
stopped at a parse error and the per-finding assertions failed on 3.11.
Samples that every supported Python parses now carry the per-finding
checks; the newer f-string forms run one per sample and accept either the
specific finding or the parse error.

Also flag unquoted X | Y annotations, which can fail at definition time
before 3.10, and check that a quoted union is not flagged.
2026-11-05 13:40:32 -05:00
montjeffrey e56624d8f1 test(clv2): catch 3.8 and 3.12 f-string forms in the compat guard
ast.parse(feature_version=...) on current Pythons goes no lower than the
3.7 grammar, and it accepts f-string forms that older interpreters reject:
the self-documenting {x=} (3.8) and, from 3.12, reused quotes, backslashes
and comments inside a replacement field. ast does not record these, so
the guard now reads each f-string's own source text. The sample file
proves both kinds are flagged and that 3.6-valid fields ({n == 1},
{n!r:>4}, escaped {{n=}}) are not.
2026-11-04 11:45:32 -05:00
montjeffrey e41a4a0492 feat(clv2): tell instinct-cli users on an end-of-life Python to upgrade
instinct-cli keeps running on old interpreters, but people on one should
know they no longer get security fixes. On a Python older than 3.11 (3.10
reached end of life in October 2026) the CLI now prints one line to
stderr after parsing its arguments:

  [instinct-cli] Python 3.8 is past end of life. instinct-cli still runs
  on it; upgrade to Python 3.11 or newer for security fixes.

The command itself runs as before. The notice stays out of automated
output: `prune --quiet`, which observer-loop.sh runs, skips it, and
CLV2_SKIP_PYTHON_EOL_NOTICE=1 turns it off for anyone who keeps an old
Python on purpose. The threshold is one constant, _SUPPORTED_PYTHON, to
raise as versions age out. Importing the module prints nothing.
2026-11-04 11:30:07 -05:00
montjeffrey 6053e1a11b fix(clv2): keep instinct-cli running on Python 3.6 and newer
The hooks fall back to any Python 3 that runs, so users on an older
interpreter (RHEL 8's 3.6, for one) still reach instinct-cli. It failed
there at import: builtin generics such as list[dict] in signatures are
evaluated when the function is defined, which raises TypeError before
3.9, and str.removeprefix is 3.9+.

- Quote the builtin-generic annotations. Type checkers read them the
  same way, and they stay valid under 3.14's deferred annotations.
- Strip the byte-order mark with startswith and a slice.
- Open the registry lock file with an explicit UTF-8 encoding.
- Say in the module docstring that 3.6 is the floor and what keeps it.

The new test parses the script with the oldest grammar ast offers and
rejects what a grammar check cannot see: unquoted builtin generics in evaluated
annotations, `from __future__ import annotations`, and 3.7+ methods and
keywords (capture_output, text, removeprefix and similar). A sample file
proves it catches each of those. It also runs import, status, export,
evolve, projects and prune under -X dev -X warn_default_encoding
-W error, so any deprecation or default-encoding warning on the current
Python fails the build. CI runs only current Pythons; this is a static
guard, not a run on a real 3.6.
2026-11-04 11:28:28 -05:00