microsoft / pyright

Static Type Checker for Python
Other
13.13k stars 1.4k forks source link

Invalid stubs for ExifRead library #8496

Closed vinicius507 closed 1 month ago

vinicius507 commented 1 month ago

Describe the bug

Pyright throws misleading diagnostics on the ExitRead library due to pyright internal stubs of the library being incorrect.

Code or Screenshots

import exifread  # ExifRead==3.0.0

def parse_exif_data(file: BinaryIO):
    logging.info("Parsing EXIF data from %s", file.name)
    tags = exifread.process_file(file)
    logging.info("Image %s has %d tags", file.name, len(tags))

image

The process_file function has the following signature:

def process_file(fh: BinaryIO, stop_tag=DEFAULT_STOP_TAG,
                 details=True, strict=False, debug=False,
                 truncate_tags=True, auto_seek=True, extract_thumbnail=True)

While the stubs have the following signature:

def process_file(
    fh: Reader,
    stop_tag: str = "UNDEF",
    details: bool = True,
    strict: bool = False,
    debug: bool = False,
    truncate_tags: bool = True,
    auto_seek: bool = True,
) -> dict[str, Any]: ...

Environment

erictraut commented 1 month ago

Pyright bundles stubs from the community-maintained typeshed project. If you think there's a bug in these stubs, please file a bug report or PR in that project.

vinicius507 commented 1 month ago

Awesome. Thanks @erictraut. You may close the issue if need be.