Skip to content

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

@adamtheturtle

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions