[Feature]: type check tests/, the last ignore_errors block

Open
#2,618 9 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@NaCr05 is already working on this.

Since Oct 29, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start by examining pyproject.toml to locate the ignore_errors block for tests. The immediate blocker is in tests/annotators/test_utils.py line 142, which imports via src. You'll need to decide whether to exclude that file or refactor the import using importlib. Then, run mypy on individual test directories (like validators/, geometry/) to see the errors, focusing on the error types listed (arg-type, attr-defined, union-attr, type-arg). Add type annotations to test functions if disallow_untyped_defs is kept. Done when mypy passes on the test directories you've cleared, and the ignore_errors block for tests.* is removed.

Written by the indexing model from the issue text.

Description

enhancement
Search before asking
  • I have searched the issues and discussions and found no similar feature request.
Feature Description

What: drop tests.* from the ignore_errors overrides in pyproject.toml so the test suite gets type checked too.

Why: #2091 set mypy up with examples.* and tests.* exempt, and the source side has been cleared out since (#2172 was the last of those). tests.* is the only block left. so here's what it actually costs, rather than guessing.

measured at 0080df0 with mypy 2.3.1 and the flags the pre-commit hook actually passes (--ignore-missing-imports --scripts-are-modules), each directory on its own with --follow-imports=silent. the source-only control comes back Success: no issues found in 90 source files, so none of this is my environment.

directory strict without disallow_untyped_defs
validators/ 0 0
geometry/ 2 1
classification/ 4 4
cv2/ 5 5
root files 10 9
draw/ 21 21
annotators/ 125 30
utils/ 130 65
dataset/ 150 140
key_points/ 183 84
metrics/ 219 103
detection/ 332 307
whole tree 1192 780

there are two things i'd rather get your call on before writing any code.

there's a blocker you hit immediately. tests/annotators/test_utils.py:142 does from src.supervision.draw.color import ColorPalette, inside a test whose entire point is that the src namespace resolves. with mypy_path = src, mypy sees src/supervision/draw/color.py under two module names and gives up on the whole run:

error: Source file found twice under different module names:
"supervision.draw.color" and "src.supervision.draw.color"

that's a module resolution error, not a line one, so # type: ignore does nothing for it. you either exclude that one file or reach the src namespace through importlib so mypy only ever sees one path. the second keeps the test meaningful but does change what it asserts, so it's your call. every number in the table above has that file excluded.

and one flag decides half the work. 565 of the 1192 are no-untyped-def, which is just -> None on test functions. it's most of the diff and it doesn't catch anything. the rest is the part that's actually worth having:

156  arg-type
157  attr-defined   (mostly pytest.raises and mock.patch context managers)
106  union-attr
 76  type-arg       (bare ndarray)

so, full strict on tests, or strict minus disallow_untyped_defs for tests.*? happy either way, i'd just rather agree it once than change my mind about it five directories in.

if you want this at all, validators/ is already clean and the next four are all under 25, so it can go in small increments the same way the source exemptions did.

Are you willing to submit a PR?
  • Yes I'd like to help by submitting a PR!
Dominant language
Python
Stars
51.6k
Forks
5k
Avg merge
1d 17h
Merged PRs (30d)
191

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from roboflow/supervision

All issues in roboflow/supervision

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.