Skip to content

check_purity: the __future__ exemption and an import's names, three gaps (raised by #599) #600

Closed

Description

@don-petry

Raised by the reads of the last fix round of #599, which closes #593. tools/check_purity.py's _special refuses a name written __x__ wherever the Kernel's syntax tree holds one, with one exemption: the module of from __future__ import. The reads found these gaps at 5dfa5f9. None is used on main, and each needs a Kernel file the check already reads.

Gap Example Fix
A relative import of a Kernel module named __future__ passes the exemption, which does not read ImportFrom.level kernel/__future__.py defines g; kernel/x.py has from .__future__ import g. The absolute from kernel.__future__ import g is refused Exempt __future__ only when the import is not relative (not node.level). Add a boundary case and a mutant that drops the level test
No test holds that __future__ is refused outside an import's module Mutating field == "module" and part == "__future__" to part == "__future__" lets def f(__future__): and from kernel.terms import run as __future__ pass, and every test still passes Boundary cases for both, and that mutant
No test notices an import's names being read twice Dropping ast.alias from the skip in _special reports from kernel.terms import __dict__ as ns at line 1 and again at line 0 on Python 3.9; caught matches the first Assert that exactly one problem names __dict__ there, and a mutant that drops ast.alias

Done when

Each gap is closed by the check, with a boundary case in tests/test_tools.py and a mutant that a test kills. Main still passes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions