Skip to content

Pyright reportUnknownMemberType on Pytester.makepyfile / maketxtfile (params lack annotations) #14396

Description

@adamtheturtle

Pytester.makepyfile and Pytester.maketxtfile are declared as def makepyfile(self, *args, **kwargs) -> Path, with no annotations on the params. Pyright strict (and basedpyright default) report reportUnknownMemberType at every call site. The sibling makefile is annotated as *args: str, **kwargs: str and is fine.

Minimal repro:

# repro.py
from pytest import Pytester

def test_x(pytester: Pytester) -> None:
    pytester.makepyfile("def test_inner() -> None: pass")
// pyrightconfig.json
{ "typeCheckingMode": "strict" }
$ pyright repro.py     # pytest==9.0.3, pyright==1.1.408
repro.py:4:5 - error: Type of "makepyfile" is partially unknown
  Type of "makepyfile" is "(...) -> Path" (reportUnknownMemberType)

Proposed fix: annotate both methods as *args: str, **kwargs: str to match makefile. #14080 already implements this; opening this issue to give it user-facing motivation.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions