Skip to content

Improvements around stubtest #3728

Closed
Closed
@hauntsaninja

Description

@hauntsaninja

Creating this issue to discuss and document areas of improvement from using stubtest. Note when I use "in CI" below, I mean as in current draft pull request #3727

  • Fixing existing errors and burning down the whitelists. Some notes:
    • Watch out for unnecessary branches. inspect.signature sometimes throws, in which case stubtest doesn't analyse further. However, the functions it fails for differ from python version to python version. If you're not sure whether you need to branch on version, run stubtest without the branch (the documentation is also helpful).
    • Similarly, as per discussion in How much do we care about positional-only args? #3693, in CI, we don't check positional-only accuracy for versions other than py38, so don't branch for that.
    • For whitelist entries that shouldn't be fixed, it might be worth adding comments to save effort and prevent others from attempting the fix (e.g., cmath.log). For avoidable stubtest false positives, please tag me!
    • To see existing errors, check the links in Better testing of stubs #754 (comment) (I've kept them up-to-date) — or run stubtest yourself!
  • In CI, we run stubtest with --ignore-missing-stub. Running stubtest without this flag is an easy way to find missing stubs to add.
  • In CI, we only run on Linux. Running stubtest on different platforms could be a good way of fixing platform differences/availability (be careful about --ignore-missing-stub).
  • In CI, we only check stdlib. Running stubtest against third party stubs would be good (potentially in CI as well).
  • Note that new Python releases will require reworking of the whitelists. This can apply to point releases too (which would break CI), e.g, when the backport of https://bugs.python.org/issue39493 gets released and Travis updates.
    • Stubtest can be useful for helping update typeshed, see details:

Changes:

python3.8 stubtest.py --custom-typeshed-dir ~/dev/typeshed --ignore-missing-stub --check-typeshed --generate-whitelist > py38wl.txt
python3.9 stubtest.py --custom-typeshed-dir ~/dev/typeshed --ignore-missing-stub --check-typeshed --whitelist py38wl.txt

Additions:

python3.9 stubtest.py --custom-typeshed-dir ~/dev/typeshed --ignore-missing-stub --check-typeshed --generate-whitelist > py39wl.txt
python3.8 stubtest.py --custom-typeshed-dir ~/dev/typeshed --check-typeshed --generate-whitelist > py38wl2.txt
python3.9 stubtest.py --custom-typeshed-dir ~/dev/typeshed --check-typeshed --concise --whitelist py38wl2.txt --whitelist py39wl.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions