pytest-dev/pytest · error · TypeError

no {name!r} checker available for {self.path!r}

Error message

no {name!r} checker available for {self.path!r}

What it means

The legacy py.path.local Checkers._evaluate method resolves each keyword passed to path.check(**kw) by attribute lookup on the Checkers instance. Valid checkers include: exists, link, dir, file, dotfile, ext, basename, basestarts, relto, fnmatch, endswith (and their not* inverses like notdir, notfile). If the keyword name matches none of these and is not a not*-prefixed valid checker, pytest raises TypeError naming the unknown checker and the path.

Source

Thrown at src/_pytest/_py/path.py:86

        return str(self.path).endswith(arg)

    def _evaluate(self, kw):
        from .._code.source import getrawcode

        for name, value in kw.items():
            invert = False
            meth = None
            try:
                meth = getattr(self, name)
            except AttributeError:
                if name[:3] == "not":
                    invert = True
                    try:
                        meth = getattr(self, name[3:])
                    except AttributeError:
                        pass
            if meth is None:
                raise TypeError(f"no {name!r} checker available for {self.path!r}")
            try:
                if getrawcode(meth).co_argcount > 1:
                    if (not meth(value)) ^ invert:
                        return False
                else:
                    if bool(value) ^ bool(meth()) ^ invert:
                        return False
            except (error.ENOENT, error.ENOTDIR, error.EBUSY):
                # EBUSY feels not entirely correct,
                # but its kind of necessary since ENOMEDIUM
                # is not accessible in python
                for name in self._depend_on_existence:
                    if name in kw:
                        if kw.get(name):
                            return False
                    name = "not" + name
                    if name in kw:
                        if not kw.get(name):

View on GitHub (pinned to 0d6fbdeffa)

Solutions

  1. Use a valid checker name: file, dir, link, exists, dotfile, ext, basename, basestarts, relto, fnmatch, endswith.
  2. For negation, prefix with not: path.check(notdir=1), path.check(notfile=1).
  3. Prefer the modern pathlib API (Path.is_dir(), Path.is_file()) for new code; py.path is legacy.

Example fix

# before
path.check(direktory=1)
# after
path.check(dir=1)
Defensive patterns

Strategy: type-guard

Validate before calling

VALID_CHECKERS = {
    'exists', 'link', 'dir', 'file', 'dotfile', 'ext',
    'basename', 'basestarts', 'relto', 'fnmatch', 'endswith',
}
def validate_check_kwargs(kw: dict) -> None:
    for name in kw:
        base = name[3:] if name.startswith('not') else name
        if base not in VALID_CHECKERS:
            raise TypeError(f'no {name!r} checker available; valid: {sorted(VALID_CHECKERS)}')
# usage
validate_check_kwargs({'dir': 1})
path.check(dir=1)

Type guard

VALID = {'exists','link','dir','file','dotfile','ext','basename','basestarts','relto','fnmatch','endswith'}
def is_valid_checker(name: str) -> bool:
    base = name[3:] if name.startswith('not') else name
    return base in VALID

Prevention

When it happens

Trigger: Calling path.check(unknownname=1); path.check(mispelled=1) (e.g., direktory, diretory); path.check(directory=1) instead of dir=1. Triggered at Checkers._evaluate (src/_pytest/_py/path.py:85-86).

Common situations: Migrating from pathlib (which uses .is_dir()) and guessing py.path checker names; typos in checker names; using a checker name from an older py library version.

Related errors


AI-assisted analysis of pytest-dev/pytest@0d6fbdeffa (2026-08-11). Data as JSON: /api/errors/9d95654a604841a7. Report an issue: GitHub.