mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-02 02:41:15 -03:00
Adds [`Vermin`](https://github.com/netromdk/vermin) to make sure our user facing Python scripts conform to the proper minimum Python version requirements. The tool parses Python code into an AST and checks it against a database of rules covering Python 2.0-3.13. Testing Python version compatibility is tricky because most issues only show up at runtime. Type annotations like `str | None` (Python 3.10+) compile just fine (under pyc) and they don't throw an exception until you actually call the relevant function. This makes it hard to catch compatibility bugs without running the code (through all possible execution paths) on every Python version. Signed-off-by: seg6 <hi@seg6.space> Closes #12044
29 lines
743 B
Fish
29 lines
743 B
Fish
#RUN: %fish %s
|
|
#REQUIRES: command -v uvx
|
|
|
|
set -l webconfig (status dirname)/../../share/tools/web_config/webconfig.py
|
|
set -l create_manpage (status dirname)/../../share/tools/create_manpage_completions.py
|
|
set -l min_version 3.5
|
|
|
|
# use vermin to detect minimum Python version violations
|
|
# features enabled:
|
|
# - union-types: catch `str | None` syntax (3.10+)
|
|
# - fstring-self-doc: catch f'{var=}' syntax (3.8+)
|
|
set -l output (uvx vermin \
|
|
--no-tips \
|
|
--violations \
|
|
--feature union-types \
|
|
--feature fstring-self-doc \
|
|
--target=$min_version- \
|
|
$webconfig \
|
|
$create_manpage \
|
|
2>&1 | string collect)
|
|
set -l exit_code $pipestatus[1]
|
|
|
|
echo $exit_code
|
|
# CHECK: 0
|
|
|
|
if test $exit_code -ne 0
|
|
echo $output >&2
|
|
end
|