Skip to content
Snippets Groups Projects
Commit 662b08ac9869 authored by Matt Harbison's avatar Matt Harbison
Browse files

tests: enforce the use of `from __future__ import annotations`

A recent MR and a separate recently landed MR that extracted code to a new file
overlooked this, so I think it's worth flagging to ensure consistency.  We don't
enforce the import for empty files (like `__init__.py`).

I'd rather this go into `import-checker.py`, but the import of interest only
happens at the top of the file, and its `verify_modern_convention()` calls
itself recursively as it transits the AST where the annotations might be.  After
a few hours of hacking on trying to get it to enforce the import, but only if
annotations are used in the module (we generally don't have or check annotations
in test files, so don't need this import), I gave up and resorted to this.  It
won't handle multi-line imports, but this isn't something I'd expect to change
often, so this is good enough for now.
parent 99615755fb8e
No related branches found
No related tags found
2 merge requests!1292Draft: 7.0rc preparation,!1121graft_cmd fixups
......@@ -43,3 +43,10 @@
> -X tests/test-verify-repo-operations.py \
> -X tests/test-extension.t \
> | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
All files that get type checked must have 'from __future__ import annotations'
$ testrepohg files 'set:**.py and size(">0")' -I mercurial -I hgext -X mercurial/thirdparty -0 \
> | xargs -0 grep -L '^from __future__ import annotations$'
mercurial/cmd_impls/graft.py
mercurial/testing/ps_util.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment