Skip to content

monkeypatch: annotate the path parameter of syspath_prepend - #14988

Open
adamtheturtle wants to merge 2 commits into
pytest-dev:mainfrom
adamtheturtle:syspath-prepend-annotation
Open

monkeypatch: annotate the path parameter of syspath_prepend#14988
adamtheturtle wants to merge 2 commits into
pytest-dev:mainfrom
adamtheturtle:syspath-prepend-annotation

Conversation

@adamtheturtle

@adamtheturtle adamtheturtle commented Sep 8, 2026

Copy link
Copy Markdown

MonkeyPatch.syspath_prepend had no annotation on its path parameter. Under a strict type checker such as pyright, every call in a user's test suite is then reported as reportUnknownMemberType, so each call needs an ignore comment.

This annotates it as str | os.PathLike[str], matching MonkeyPatch.chdir next to it. The method already converts the argument with str(), so behaviour is unchanged.

  • Add yourself to AUTHORS
  • Changelog entry (added as changelog/<PR number>.improvement.rst once the number was known)

adamtheturtle and others added 2 commits September 8, 2026 07:06
The parameter had no annotation, so a strict type checker such as
pyright reports every call as having a partially unknown type. The
method accepts anything str() can turn into a path, and it is
documented alongside chdir, which already takes str | os.PathLike[str].

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant